Have you tried prototypes?
Briefly. I don't fully grok the try/catch example in perldoc perlsub, so I may be missing something, but my failed attempts look like:
#! /usr/bin/perl
use strict;
use warnings;
sub curry(&@)
{
my ($fn, @args) = @_;
return sub {
$fn->(@args, @_);
}
}
&curry(+, 2)->();
which of course does not compile. (There's also the issue
that in order to
really do higher-order functions with prototypes, I'd need to somehow examine
fn's prototype and preserve it in the returned sub.)
I'm thinking that a source filter might help, turning builtins used as values into anonymous subs, but I don't know very much about source filters — I'm not even
sure that they do what I think they do.
--
Yours in pedantry,
F
o
x
t
r
o
t
U
n
i
f
o
r
m
"Anything you put in comments is not tested and easily goes out of date." -- tye