Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"our sub Long::Package::name {...}" Doesn't DWIM #5898

Open
p6rt opened this issue Dec 20, 2016 · 1 comment
Open

"our sub Long::Package::name {...}" Doesn't DWIM #5898

p6rt opened this issue Dec 20, 2016 · 1 comment

Comments

@p6rt
Copy link

p6rt commented Dec 20, 2016

Migrated from rt.perl.org#130378 (status was 'new')

Searchable as RT130378$

@p6rt
Copy link
Author

p6rt commented Dec 20, 2016

From dabe@dabe.com

Vis-a-vis the following​: http://dabe.com/misc/perl6-class_method.html

## Foo.pm

  class Foo​::Bar { has $.var }
  $Foo​::var = 42;

  package Foo { our sub x { say "X" } }
  &Foo​::y = sub { say "Y" };
  our sub Foo​::z { say "Z" }

## foo.p6

  #!/usr/bin/env perl6

  use lib $*PROGRAM.resolve.dirname;
  use Foo;

  Foo​::Bar.new; # OK
  say $Foo​::var; # OK​: 42

  Foo​::x; # OK​: X
  Foo​::y; # OK​: Y
  Foo​::z; ## X​::AdHoc.new(payload => "Could not find symbol '\&z'")

There was some discussion on #perl6
<https://irclog.perlgeek.de/perl6/2016-12-09> about whether the compiler
should disallow such long names [psch++], or whether it should stuff it
in a package and vivify it for you [jnthn++].

IMHO, as a typical perl5 switcher, jnthn's solution seems the most
DWIM-ish --- and since the other alternatives offer just as much "spooky
action at a distance", it seems surprising that "our sub
Long​::Package​::name" wouldn't have the same effect.

Just my 2¢... :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant