On 14.11.2012 22:23, Toby Inkster via RT wrote:
Show quoted text> Say, for Catalyst handlers, which rather than just being invoked on
> $self, also always have their next parameter as the context object $c.
>
> use Function::Parameters handler => {
> name => 'required',
> shift => [qw( $self $c )],
> check_argument_count => 1,
> };
I'm very reluctant to add this feature. It's too much magic.
By implicitly declaring variables you can no longer see where a variable
was introduced and what its scope is. I'm willing to make an exception
for $self in methods because it's so ubiquitous and everyone recognizes
the idiom.
But even the ability to rename $self provided by the 'shift' feature is
of dubious worth. I implemented it because $self makes no sense in class
methods, so you want something like $class there. But then you need a
different keyword, and there's nothing as universally recognized as
'method' is. So this feature would let you create a custom keyword that
(hopefully) makes sense for your application. (This was all before the
$invocant: feature was added.)
Wouldn't 'method foo($c) { ... }' work just as well?