[Israel.pm] Using Closures as Methods

Jason Elbaum jason.elbaum at gmail.com
Thu Feb 9 07:49:02 PST 2006


Interesting code. Though it's not clear to me why one would ever
expect this *not* to work in the first place. SUPER is a mechanism for
method search; methods are simply subroutines; closures are a type of
subroutine. Makes sense to me.

More to the point, though: Why would you want to do this? What
functionality does it give you in real-world code?

Objects let data carry its own functions with it; closures let
functions carry their own data with them. It's not clear to me what
you gain by combining the techniques. Better encapsulation of object


Jason Elbaum

More information about the Perl mailing list