Damian Conway:

> My forthcoming proposal will be that invocants still be passed as $_[0]
> by default, but that there be a pragma allowing $_[0] to be automagically
> shifted somewhere else during dispatch. For example:
>
>
>       sub method { print "I was called through: $_[0]";
>                    print "My args were: @_[1..$#_]";  }       #default

>       use invocant '$ME';
>       sub method { print "I was called through: $ME";
>                    print "My args were: @_";          }

Why couldn't(/shouldn't/wouldn't) this be more useful as a facility that
allows you to define a chunk of code that gets inserted in each sub routine?

I'm not sure what the general facility would look like, but it seems to me
like the "use invocant '<variable>'" pragma is just essentially sticking a:

        my <variable> = shift ;

as the first line in each method... wouldn't it be more fun to let people do
something like:

        use invocation 'my $ME = shift; print "I was called through : $ME" ;
print "My args were : @_" ;'

... which, of course, means that duplicating the method above is as simple
as:

        sub method {  # use invocation stuff gets shoved in here
        }

(Or, was it already intended that the implementation of 'use invocant' might
be some sort of compile-time macro?)

Dirk
        

Reply via email to