Applying Operators to Coderefs

In algebra, there's this pretty funky concept:

(f+g)(x) = f(x) + g(x)

And I was thinking if $f and $g were coderefs, what could $f + $g be?

It turns out with a little bit of overload magic, you can get coderefs to behave pretty much how functions do in algebra.

Sub::Operable is on CPAN.

Leave a comment

About Toby Inkster

user-pic I'm tobyink on CPAN, IRC and PerlMonks.