develooper Front page | perl.perl6.language | Postings from February 2012

Re: Setting private attributes during object build

Thread Previous | Thread Next
From:
Moritz Lenz
Date:
February 1, 2012 23:32
Subject:
Re: Setting private attributes during object build
Message ID:
4F2A3BD5.5070808@faui2k3.org
On 02/02/2012 07:40 AM, Damian Conway wrote:
> My point was that I don't want the named arguments that BUILD can take
> to be restricted to only the names of public attributes...which was, I
> thought, yary's complaint when writing:

No, the complaint was that when you write self.bless(*, |%named) in your
method 'new', then you have to list each private attribute as

submethod BUILD(:$!a, :$!b, ...) { }

in order for them to be bound to their values.

This is necessary since the change that private attributes cannot be
initialized from the default 'new' constructor, because it's 'bless' (or
the 'BUILDALL' that bless calls) that distinguishes private and public
attributes, not 'new'

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About