Scott wrote:
 
   > Actually, I think it becomes:
   > 
   >    sub foo is method {
   >       my $old = .foo;
   >       .foo = shift if @_;
   >       return $old;
   >    }
   > 
   > But, I could be wrong.  Any Damians care to enlighten?  :-)

Well, I'm not a Damian, but I play one on perl6-language. ;-)

The final syntax for new-style Perl6 OO is currently "in flux", or
perhaps we should say: "its superposition has yet to collapse to a
stable eigenstate". Larry has ideas, I have ideas, and I'm working on
integrating them into a coherent proposal.

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;
            }
        }

Though, in fact, the idiom in Perl 6 would probably be to use 
just use lvalue methods:

        class Demo {

            my $.foo;

            method foo is lvalue {
                return $.foo
            }
        }


Nor am I yet convinced of the need for a separate C<$.attribute> syntax,
so it *might* just be:

        class Demo {

            my $foo;

            method foo is lvalue {
                return $foo;
            }
        }


The unary dot operator would only be used for method calls:

        method bar {
                my $realfoo = .foo;
                .foo = 'bar';
                .baz();
                .foo = $realfoo;
        }

to avoid the endless calls to self():

        method bar {
                my $realfoo = self.foo;
                self.foo = 'bar';
                self.baz();
                self.foo = $realfoo;
        }


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.

;-)

Damian

Reply via email to