> It is proposed that Perl reserve the bareword C<__>
(underscore-underscore)
> as a "placeholder" for generating higher order functions more cleanly.
>
But what if I want to say:
@n = (0.2, 1, 3.5, 4);
@integersInN = grep __=abs(__) @n; # @intsInN is empty!
Instead I would need:
@integersInN = grep {$_=abs($_)} @n; # @intsInN is (1,4)
Why force me to write a boring old anonymous sub here when we've got
oh-so-cool higher-order functions? What I _really_ want to write is:
@integersInN = grep _test=abs(_test) @n; # @intsInN is (1,4)--hooray!
So I'd like to see the following in the RFC:
----
It is proposed that Perl introduce a new prefix '_', which indicates a
placeholder. This can be used either as '_identifier', which creates a named
placeholder, or '__', which creates an anonymous placeholder.
----
New programmers should easily understand that:
- $foo is the variable 'foo'
- _foo is the placeholder 'foo'
- $_ is the default variable
- __ is the default placeholder.
Then, when they see the same named placeholder appear twice in the same
higher-order function, they know that each is referring to the same thing.