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 $!a outside of class definition, shouldn't #1679

Closed
p6rt opened this issue Apr 11, 2010 · 6 comments
Closed

Rakudo allows $!a outside of class definition, shouldn't #1679

p6rt opened this issue Apr 11, 2010 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Apr 11, 2010

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

Searchable as RT74274$

@p6rt
Copy link
Author

p6rt commented Apr 11, 2010

From @masak

<ash_> rakudo​: class A { has $!a }; my $a = A.new(a => 42); my $method
= method { return $!a }; $a.$method().say;
<p6eval> rakudo c41cf3​: OUTPUT«42␤»
<ash_> should that be allowed?
<moritz_> ash_​: rakudo doesn't really enforce privateness of
attributes in any case
<moritz_> ash_​: but I don't think it should be allowed
<ash_> got ya
<ash_> some languages have different ideas of 'private', but most
languages with reflection end up having all their variables public,
eventually
<TimToady> the compiler should have no idea what $!a means outside the
class's block, I think
<ash_> so, a bare "my $a = method { $!a }" would be a compiler error?
<ash_> by bare i mean, outside a class definition
<TimToady> outside of anyplace that doesn't define $!a
<TimToady> including inside a different class definition

@p6rt
Copy link
Author

p6rt commented Jun 15, 2011

From @ronaldxs

Possibly a variation of the same problem, and certainly falling under
the subject of "$!a outside of class", simply asking rakudo to
evaluate "$.a" or "$!a" gives Null PMC errors at this point. As
further noted here on IRC - http://irclog.perlgeek.de/perl6/2011-06-
14#i_3923449 and http://irclog.perlgeek.de/perl6/2011-06-14#i_3925731 -
nom does better but still seems to need some work.

@p6rt
Copy link
Author

p6rt commented Jun 15, 2011

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 13, 2012

From @jnthn

On Sun Apr 11 01​:33​:59 2010, masak wrote​:

<ash_> rakudo​: class A { has $!a }; my $a = A.new(a => 42); my $method
= method { return $!a }; $a.$method().say;
<p6eval> rakudo c41cf3​: OUTPUT«42␤»
<ash_> should that be allowed?
<moritz_> ash_​: rakudo doesn't really enforce privateness of
attributes in any case
<moritz_> ash_​: but I don't think it should be allowed
<ash_> got ya
<ash_> some languages have different ideas of 'private', but most
languages with reflection end up having all their variables public,
eventually
<TimToady> the compiler should have no idea what $!a means outside the
class's block, I think
<ash_> so, a bare "my $a = method { $!a }" would be a compiler error?
<ash_> by bare i mean, outside a class definition
<TimToady> outside of anyplace that doesn't define $!a
<TimToady> including inside a different class definition

Now it's a compile time error​:

class A { has $!a }; my $a = A.new(a => 42); my $method = method {
return $!a }; $a.$method().say;
Cannot understand $!a in this context at line 1, near " }; $a.$me"

Tagging testneeded.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jan 30, 2012

From @moritz

Now tested in S12-attributes/instance.t.

@p6rt
Copy link
Author

p6rt commented Jan 30, 2012

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

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

No branches or pull requests

1 participant