> Once a hash has been C<private>-ized, the only way to extend its set of > entries is via another call to C<private>: > > sub new { > my ($class, %self) = @_; > bless private \%self, $class; > private $self{seed} = rand; # okay > $self{seed} = rand; # dies, can't autovivify > } > can we eliminate the private keyword and perform this check on all blessed array/hash references? direct access to entries is prohibited outside of the bless()ed package: package MyAccount; @ISA = qw(BaseClass); sub new { my $class = shift; bless $class->SUPER::new(@_), $class; } sub creditBalance { self->{balance} += shift; # valid } sub debitBalance { self->{balance} -= shift; # valid } package main; $acc = MyAccount->new; $acc->{balance} *= 1000; # dies just IMHO, kenneth
- RFC 188 (v1) Objects : Private keys and methods Perl6 RFC Librarian
- Re: RFC 188 (v1) Objects : Private keys and metho... Tom Christiansen
- Re: RFC 188 (v1) Objects : Private keys and metho... Tom Christiansen
- Re: RFC 188 (v1) Objects : Private keys and metho... John Siracusa
- Re: RFC 188 (v1) Objects : Private keys and m... Piers Cawley
- Re: RFC 188 (v1) Objects : Private keys and metho... Kenneth Lee
- Re: RFC 188 (v1) Objects : Private keys and metho... Kenneth Lee
- Re: RFC 188 (v1) Objects : Private keys and m... Kenneth Lee
- Re: RFC 188 (v1) Objects : Private keys and metho... Damian Conway
- Re: RFC 188 (v1) Objects : Private keys and metho... David E. Wheeler
- Re: RFC 188 (v1) Objects : Private keys and m... Piers Cawley
- Re: RFC 188 (v1) Objects : Private keys and metho... Nathan Wiger
- Re: RFC 188 (v1) Objects : Private keys and metho... Damian Conway
- Re: RFC 188 (v1) Objects : Private keys and metho... Dave Rolsky
- Re: RFC 188 (v1) Objects : Private keys and metho... Jonathan Scott Duff
- Re: RFC 188 (v1) Objects : Private keys and metho... Damian Conway
- Re: RFC 188 (v1) Objects : Private keys and m... Tom Christiansen