Jeremy Howard wrote:
> Anyhoo, there's no reason why you can't have ^1, ^2, and so forth, _and_
> allow named placeholders too. Although I don't see what this buys you.

Argument ordering. We might be constrained by the caller as to what order
the placeholders are passed in. Also, we want to make partial application,
i.e. recurrying, as useful/simple as possible. So it's important to
have the argument order independent of where the placeholders appear
in the expression.

  my $f = (^x < ^max) ? ^x * ^scale : ^y * ^scale;

has to be called

  &$f($x, $max, $scale, $y)

First off this might not be the order the caller expects them in and
we're sunk. Also, that's a pain to re-curry if we know $max and $scale
but want $x and $y free:

  my $g = &$f(^_, 10, 2, ^_);

Seems better to just write $f as:

  my $f = (^2 < ^1) ? ^2 * ^0 : ^3 * ^0;

Alright, yeah, maybe not. That's total gibberish isn't it. ;) So how
about taking the *original* $f and rebinding the order of all the
arguments:

  my $f = &$f(^2, ^0, ^1, ^3);

And the $g becomes:

  my $g = &$f(10, 2);

Anyways, ^_ has my vote. (Although I really have a soft spot for that
Oracle SQL*Plus variable syntax... ;)

- Ken

Reply via email to