Perl 6 allows you to curry subroutines with .assuming. That's easy to do when you want to assume the leading positional parameters:
# The first one
{
sub first-and-last ( $first, $last ) {
say "Name is $first $last";
}
my &joe = &first-and-last.assuming( 'Joe' );
&joe.( 'Jones' );
}
But what if I want to assume one of the other positional parameters while leaving the first ones alone? How can I tell .assuming
which parameters to assume?
# The second one
try {
sub first-and-last ( $first, $last ) {
say "Name is $first $last";
}
my &smith = &first-and-last.assuming( Empty, 'Smith' );
&smith.( 'Joe' );
}
With named parameters this is straightforward, but that's not what I'm curious about.
If this is really just an EVAL underneath, that's kinda disappointing.