Larry Wall wrote:

    $obj does (A,B,C)

could also be made to work even with non-associative does.


Note that you _do_ want to be able to do something to the effect of
ordered composition in a single statement, though:

   role A {
       method m { ... }

   $x does A;

A.m will override $x.m - assuming that $x.m exists at all.  As such,
you end up with an anonymous class with an undefined method - a
distinct no-no.

Maybe what you need to say is that "$x does ..." is a macro that
treats what follows as part of an anonymous class definition.  So

   $x does A does B { method m { doit } }
would be equivalent to something like

   $x.WHAT := class is $x.WHAT does A does B { method m { doit } }
You'd need to have the macro work some magic involving curly-braces
and terminating semicolons, so that

   $x does A;


   $x.WHAT := class is $x.WHAT does A { }

instead of

   $x.WHAT := class is $x.WHAT does A {

And you'd have to decide what to do with

   $x does role { ... }
   { ... }

Should this become

   $x.WHAT := class is $x.WHAT does role { ... } { ... }


   $x.WHAT := class is $x.WHAT does role { ... } { }
   { ... }


But otherwise, this approach allows runtime composition to use exactly
the same syntax and semantics as compile-time composition as soon as
you hit infix:<does>.

Jonathan "Dataweaver" Lang

Reply via email to