in reply to Currying--useful examples?

You can interpret the standard way of "making a reference to a method call" as a form of currying:
my $coderef = sub { $obj->method(@_) };
There's no other way to do it, and it's pretty useful in OO programming when an interface is looking for a callback. In general, when you have to pass in a callback to some interface, you can use currying when the calling interfaces don't quite match up (the callback will be called with certain arguments, but the subroutine you have expects more/less/different arguments).

Sorry that this example is still pretty abstract.. ;)

blokhead

Replies are listed 'Best First'.
Re^2: Currying--useful examples?
by f00li5h (Chaplain) on Jan 11, 2007 at 11:19 UTC

    blokhead++ - I thought your example was neat. It's clean, and to the point.

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;