On Mon, Jan 12, 2009 at 12:33:31PM +0100, Carl Mäsak wrote:
: Writing something like this in Rakudo yesterday, I was slightly
: surprised to find it not working:
: 
: class SomeClass {
:      my $.warn_limit = 1000;
:      my $.stern_warn_limit = $.warn_limit * 1.05;
:      my $.expel_limit = $.warn_limit * 1.10;
: 
:     # ...
: }
: 
: The specific error from Rakudo is "Lexical 'self' not found", which
: translated into English means "You're trying to access an object [the
: protoobject] that doesn't exist yet".
: 
: I think that the above is a very reasonable way to declare class-scope
: variables in Perl 6, and I just wanted to get confirmation that this
: should in fact work in Perl 6. I don't see read access to class-scope
: variables from the same class scope addressed in the specification.

I suspect if we make self mean the SomeClass protoobject within
the class closure but outside of method declarations, we can
probably get it to work like you expect, presuming you don't run into
order-of-initialization issues.  And running the block should probably
be the final operation in class initialization, or very close to it.

Larry

Reply via email to