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

Non-rw attributes are not changeable from within a class in Rakudo #311

Closed
p6rt opened this issue Sep 13, 2008 · 4 comments
Closed

Non-rw attributes are not changeable from within a class in Rakudo #311

p6rt opened this issue Sep 13, 2008 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Sep 13, 2008

Migrated from rt.perl.org#58826 (status was 'rejected')

Searchable as RT58826$

@p6rt
Copy link
Author

p6rt commented Sep 13, 2008

From @masak

Rakudo r31066 works under the assumption that the absence of "is rw"
on attributes means that they cannot be modified, period. This reduces
their utility somewhat.

$ ./perl6 -e 'class A { has $.x is rw; method a { $.x = 5; } }; A.new.a' # works

$ ./perl6 -e 'class A { has $.x; method a { $.x = 5; } }; A.new.a' # fails
Cannot assign to readonly variable
[...]

$ ./perl6 -e 'class A { has $.x; method a { $!x = 5; } }; A.new.a' #
this works, though

My intiution about this may be off, but I read "is rw" as "not
_publicly_ writeable". I think even a non-rw attribute should be
changeable from within its own class.

(Substituting a "%.h" for the "$.x" causes another segmentation fault
in the failing case, by the way.)

@p6rt
Copy link
Author

p6rt commented Nov 11, 2008

From @jnthn

On Sat Sep 13 04​:18​:27 2008, masak wrote​:

Rakudo r31066 works under the assumption that the absence of "is rw"
on attributes means that they cannot be modified, period. This reduces
their utility somewhat.

$ ./perl6 -e 'class A { has $.x is rw; method a { $.x = 5; } };
A.new.a' # works

$ ./perl6 -e 'class A { has $.x; method a { $.x = 5; } }; A.new.a' #
fails
Cannot assign to readonly variable
[...]

$ ./perl6 -e 'class A { has $.x; method a { $!x = 5; } }; A.new.a' #
this works, though

My intiution about this may be off, but I read "is rw" as "not
_publicly_ writeable". I think even a non-rw attribute should be
changeable from within its own class.

The discussion that ensued on p6l, IIRC, meant that what Rakudo is doing
is the Correct Thing. So rejecting this ticket.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Nov 11, 2008

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

@p6rt
Copy link
Author

p6rt commented Nov 11, 2008

@jnthn - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Nov 11, 2008
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