What do you mean by "Where closures rock is as a way to provide optional hooks when you compile a function without paying any run-time price if the hook was not included".
Could you provide an example of what you mean?
And why is eval being used here at all? Wouldn't the following be simpler, faster, and easier to maintain?
That's what I'd call a closure (well, the subroutines returned anyway, make_divide itself isn't one, but it's return values are).sub make_divide # "Half" is a lousy name for a curried divide { my $n = shift; if (Power_Of_Two($n)) { my $log = Log2($n); return sub { return $_[0] >> $log; }; } else { return sub { return int( $_[0] / $n ); }; } }
So, as I so often ask, what am I missing?
In reply to RE: RE (tilly) 1: Fly Subroutines on the Fly
by BlaisePascal
in thread Fly Subroutines on the Fly
by Adam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |