Damian Conway wrote: > > Ah, but there's definitely a confusion as to whether it's *meant* > to be assignable. > > What if I (as the class designer) want to give you read access but not > write access to an object's name? I think this misses the mark. We're talking about functions, right? :lvalue won't save you from the situation you describe: $r->func = $x; # whew! no :lvalue saves us $r->func($x); # but not from this! oh no! What you have to do is write the function correctly: sub func { die "assigning to func attempted" if @_; $ME->{STATE}->{func}; # return "func" value } Now, if this is what you want, add a :readonly attribute: sub func : readonly { # auto-die if @_ seen $ME->{STATE}->{func}; } This saves you from both: $r->func = $x; # whew! having :readonly $r->func($x); # dies for both of these -Nate
- RFC 107 (v1) lvalue subs should receive the rvalue as ... Perl6 RFC Librarian
- Re: RFC 107 (v1) lvalue subs should receive the r... Nathan Wiger
- Re: RFC 107 (v1) lvalue subs should receive the r... Damian Conway
- Re: RFC 107 (v1) lvalue subs should receive t... Jarkko Hietaniemi
- Re: RFC 107 (v1) lvalue subs should receive t... Nathan Wiger
- Re: RFC 107 (v1) lvalue subs should receive t... Damian Conway
- Re: RFC 107 (v1) lvalue subs should recei... Nathan Wiger
- Re: RFC 107 (v1) lvalue subs should r... Nathan Torkington
- Make lvalue subs the default (wa... Nathan Wiger
- Re: Make lvalue subs the def... Piers Cawley
- Re: Make lvalue subs the... Nathan Wiger
- Re: Make lvalue subs the... Andy Wardley
- Re: Make lvalue subs the def... Jonathan Scott Duff
- Re: Make lvalue subs the... Nathan Wiger
- Re: Make lvalue subs the... Jonathan Scott Duff