I just released the invoker module on cpan, and i'd like to
propose the syntax to be included in future perls.
why: with the blooming modules providing the "method" keyword, we
no longer need to have "my $self = shift" everywhere. however
this makes "$self" now the most repeated code.
Here's the idea:
"use feature 'invocant'" enables the $-> operator. There are two
- "use invocant '$self" looks for the specific lexical variable
named $self in the current context, and bails out in compile
time if not found.
- "use invocant 'auto'" looks for the first real pad entry in the
nearest scope as the default invocant.
I am not sure which one suites as better default behaviour. the
latter seems less intrusive on insisiting variable names by can
be a bit confusing.
$-> can be parsed as $- > ($- greater than .. ), so we need to
deprecate the use of $- (and hopefully the whole format system by
requiring use of formats to add additional "use format" line.)
the feature can install a warning when accessing $- before such
What do people think?