Damian Conway wrote:
> Suppose C<with> were a built-in function with parameter list:
>
> sub with (\%; ^&) {...}
>
> That is, C<with> takes an explicit hash and -- optionally -- a block, sub
ref,
> or higher order function.
> <...>
> If C<with> is called with *both* a hash and a block/sub ref/h.o.f. as
> arguments, it still converts the hash contents to a named list, but then
> invokes its second argument on that list of arguments. So:
>
>         with %args {
>             print "Howdy, ", ^rank, " ", ^name;
>         };
>
>         # is really:
>
>         (print "Howdy, ", ^rank, " ", ^name)->(with %args);
>
>         # is really:
>
>         $tmp = sub ($name, $rank) {print "Howdy, ", $rank, " ", $name};
>         $temp->( name: $args{name}, rank: $args{rank});
>
Mmm... yummy... And placeholder names seem to be getting a real role in life
too! I wonder if hashes used as HOF arguments in general should use
placeholder names to fill in their arguments from the corresponding hash
elements. That would be even yummier!


Reply via email to