On Tue Feb 05 20:30:11 2013, RHESA wrote:
Show quoted text> I don't actually know what a subroutine entry is, precisely, but
> consider these two one-liners:
>
> perl -MMethod::Signatures::Simple -E '
> sub t (&) { $_[0]->() }
> my $x = sub { 1 };
> say t $x;
> say t func ($v) { 2 };
> '
> Type of arg 1 to main::t must be block or sub {} (not private
> variable)
> at -e line 4, near "$x;"
> Type of arg 1 to main::t must be block or sub {} (not subroutine
> entry)
> at -e line 5, near "};"
> Execution of -e aborted due to compilation errors.
>
> and:
>
> perl -MMethod::Signatures::Simple -E '
> sub t (&) { $_[0]->() }
> my $x = sub { 1 };
> say t \&$x;
> say t \&{ func ($v) { 2 } };
> '
> 1
> 2
>
> So there's some symmetry there.
>
> I don't see myself using this syntax though, so unless you feel
> strongly
> enough about it to attempt a fix, I'd recommend dropping the prototype
> on sub t, or some other workaround.
I see what you mean. Given that fund () works like a safe source filter, I was expecting that it
would be translated to sub { ... } and so I was expecting this to work. But yes, the cases you
point out are similar.
I can't drop the (&) prototype in this case because usually the function is called as t { }; (with a
bare block).
Using func() was only a bit of sugar to hide the my ($param) = @_;, so not terrible important,
and certainly not enough for me to go down that particular rabbit hole and try to understand
how to improve on this.
Thanks for your time,