On Sat, Oct 27, 2001 at 08:09:57AM +1000, Damian Conway wrote: > Larry has ideas, I have ideas...
All good so far ;-) > However, I don't think the above syntax will be it. I think it would likely > be closer to: > > class Demo { > > my $.foo; > > method foo { > my $old = $.foo; > $.foo = @_[1] if @_ > 1; > return $old; > } > } Several questions come up. * If $.foo is "like" the Perl5 $self->{foo}, how do I do the Perl5 $self->foo? * Is "foo" in this context an auto-quoted key, or an actual entry in the namespace? I ask because I'm trying to find out how this interacts with Perl's (un)reserved words. print $.if 1; # comes to mind * Do you always have to use parens now for method invocation? > Though, in fact, the idiom in Perl 6 would probably be to use > just use lvalue methods: Ok, had missed that one. Using an lvalue method seems super-nifty. > Nor am I yet convinced of the need for a separate C<$.attribute> syntax, > so it *might* just be: That certainly eliminates many of my above concerns. > class Demo { > > my $foo; > > method foo is lvalue { > return $foo; > } > } Hmmm... I'm trying really hard to get my head 'round this. So, a class is a scope which creates a new closure every time it's instantiated? This is intriguing. Certainly it removes any question of unauthorized member access. I'm quite curious to see what the initialization syntax will be like. Will there be a special initialization method, or will we have something like a BEGIN block inside the class? How would this play with constants? > Aaron then asked: > > > Also, the "sub .foo" syntax is one I've now seen in an apocolypse and > > the good ensign's article, so I'm not sure where "sub foo is method" is > > coming from. > > Those alternate universe syntaxes coming from quantum fluctuations in > the uncollapsed syntax superposition. I'll soon be firing a polaron > burst through the main deflector in a desparate attempt to stabilize > this anomoly before it destroys Perl 6. Oh, just send the boy. He solves these problems in every episode ;-) Seriously, it would be nice to have a BNF somewhere, even if it changed every day, and had a few "alternates" sections... I'd be interested in starting this if no one else has their heart set on doing it. Perhaps I could get it into a CVS archive so that we can all edit it on our own branches. I'm not proposing anything super-useful for actually cranking out Perl6's perly.y, but just a high-level view of the operators and essential syntax. $ee =~ y/ou/l8/r; -- Aaron Sherman [EMAIL PROTECTED] finger [EMAIL PROTECTED] for GPG info. Fingerprint: www.ajs.com/~ajs 6DC1 F67A B9FB 2FBA D04C 619E FC35 5713 2676 CEAF "Write your letters in the sand for the day I'll take your hand In the land that our grandchildren knew." -Queen/_'39_