Nick Ing-Simmons wrote:

We have been discussing how to pass data to Tk callbacks.
In particular Entry widget validation routines.
There are a number of items that they _might_ be interested in but a typical routine would only use a few.
Currently it passes them all as positional parameters.


One idea that occured to me/us is to have a "localized" hash for this purpose (which might be tied/magical).

One choice of name for this is %_ - which fits neatly with @_ for positional args and $_ as current thing.

Also *_ glob already exists to have its GvHV entry (ab-)used.

What does p5p think of this use ?

Basically @_ says "how" you been called $_ is "what" you are working on, and this idea gives %_ the meaning of "why".
(Caller gives the "who" ;-) )

From a Perl 6 perspective, it seems likely that C<%_> will be the name commonly used for the "slurpy hash" of a subroutine. Just as C<@_> will often be the name used for the "slurpy array". See Exegesis 6 for more details.


Indeed, when it comes to object constructors (all of which implicitly have a slurpy hash), C<%_> might well be the automatically provided name for that hash. See Exegesis 12 for more details. ;-)

Hence, making C<%_> mean something different in core Perl 5 might possibly be "forwards incompatible".

Damian

Reply via email to