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

Rakudo allows the declaration of a sub with the same name as an already declared class, STD doesn't #2071

Closed
p6rt opened this issue Aug 14, 2010 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 14, 2010

Migrated from rt.perl.org#77224 (status was 'resolved')

Searchable as RT77224$

@p6rt
Copy link
Author

p6rt commented Aug 14, 2010

From @masak

<masak> std​: class A {}; sub A {}
<p6eval> std 31912​: OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Illegal
redeclaration of routine 'A' [...] FAILED 00​:01 112m␤»
<masak> rakudo​: class A {}; sub A { say "OH HAI" }; say A.new; A()
<p6eval> rakudo 9e1bcd​: OUTPUT«A()<0x6ec9d70>␤OH HAI␤»
* masak submits rakudobug
<masak> std​: sub A {}; class A {}
<p6eval> std 31912​: OUTPUT«ok 00​:02 112m␤»
<jnthn> erm.
<masak> rakudo​: sub A { say "OH HAI" }; class A {}; say A.new; A()
<p6eval> rakudo 9e1bcd​: OUTPUT«A()<0x6ecdba0>␤OH HAI␤»
<masak> at least Rakudo is consistent. :)
<jnthn> I think Rakudo has it right there, fwiw.
<jnthn> Subs get stashed with an & sigil
<jnthn> So there's not an ambiguity.
<masak> in some sense classes and subs share the same namespace, though.
<masak> above, they're both referrable to as 'A'.

I find it curious that STD.pm6 warns in the class-then-sub case, but
not in the sub-then-class case.

Also, I'd like to hear more about the side that jnthn is representing
here, because so far all I've been hearing is that Perl 6 conflates
the namespace for classes and subroutines, and that's why only one of
them can be referred to before they're declared. (See
<http://www.mail-archive.com/perl6-all@&#8203;perl.org/msg87478.html>.)

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @moritz

I'm now fairly certain this is not a bug. The namespaces themselves are
not conflated (subs stored with a & sigil), and there are clear
disambiguation rules (round parens after the thing indicate the subroutine).

Closing.

@p6rt
Copy link
Author

p6rt commented May 29, 2012

@moritz - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed May 29, 2012
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant