in reply to Re^2: converting libraries into modules
in thread converting libraries into modules

chromatic,
While I tend to agree that having single functions that works as a method and an exportable function is usually a bad idea, your solution seems a bit over the OP's head. Would you mind providing a code sample, point to an existing wheel, or link to some documentation that does a better job explaining.

For what it is worth - I really like that Perl6 will distinguish between methods and subs as well as provide multi-method dispatch.

Cheers - L~R

  • Comment on Re^3: converting libraries into modules

Replies are listed 'Best First'.
Re^4: converting libraries into modules
by chromatic (Archbishop) on Mar 06, 2006 at 00:08 UTC

    It could be as simple as:

    use vars '@EXPORT'; @EXPORT = qw( list of methods to curry ); sub import { my $class = shift; my $curried_object = $class->new(); my $caller = caller(); for my $export ( @EXPORT ) { *{ $caller . "::$export" } = sub { $curried_object->$export( @ +_ ) }; } }
      I like this one, it's very clever and it will even work with InsideOut or closure objects, that's great :)