On Thu, Oct 25, 2001 at 04:53:46PM -0500, Garrett Goebel wrote: > Piers Cawley has written a nice article entitled: "Perl 6 : Not Just For > Damians".
I had missed what unary . really did, and this explained it to me. I'm now much more excited about it as a "with"-like operator. It does make me think, though... Would it make sense to have an accessor operator? For example, in Perl5 I would do this: sub foo { my $self = shift; my $old = $self->{foo}; # So $obj->foo(undef) will work if (@_) { $self->{foo} = shift @_; } return $old; } In Perl6 with the unary ., that becomes: sub .foo (*@args) { my $old = $.{foo}; # So $obj.foo(undef) will work $.{foo} = shift @args if @args; return $old; } So, since this is likely to be fairly common, could we perhaps have a shortcut? sub .{foo} () {} Of course, this is the simple case. In reality, the transformation would be: sub .{NAME} () BLOCK which becomes sub .NAME (*@args) { BLOCK my $old = $.{NAME}; $.{foo} = shift @args if @args; return $old; } The syntax might not be wise. I dunno how I feel about YAUB (Yet Another Use of Braces). Perhaps some syntax like: accessor .NAME () BLOCK But the .{method} syntax does seem to be a very ovious meaning, given what .{NAME} is going to mean inside of the method. Then again, we could call it all quits and come up with a naming convention that allows some members to be automatically exported as methods, and others to be withheld. -- 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_