I just reread the section of A6 about currying, and I have several questions about it.
1) Suppose I have a function like the following: sub foo($param, @param) {...} where the parameter names differ only by their sigils. Is it legal for me to type &foo.assuming('$param' => 1) in order to disambiguate the parameter names? 2) Often, if you are working with a code reference instead of an actual sub, you might not know the names of all the parameters. In this case, would it be legal to curry by parameter position instead of parameter name? sub setFirstToOne(&block) { &block.assuming( 0 => 1); #I am assuming 0-based parameter lists } Another advantage of currying by position is that it might allow you to set the first few elements of a slurpy array. sub foo(* @params) {...} my $bar = foo.assuming(0 => "hello"); $bar.("world"); # Calls foo("hello", "world") 3) Currying binds a function parameter to a value? Is there any way to bind a function parameter to a variable? Consider the following code: sub printNum(int $x) {print "$x\n";} my $foo = 0; my $vindaloo = &printNum(int).assuming(x => $foo); #currying ++$foo; $vindaloo.(); This code prints 0, not 1, because the currying binds the parameter to the value $foo had when the currying occurred, not the value it had when the curried function was called. It would be nice if there were some way to curry so that a parameter is bound to a variable reference. This would probably have to be a different method than assuming. Maybe something like &printNum(int).bind(x => \$foo) Joe Gottman