Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Near-free function currying in Perl

by tmoertel (Chaplain)
on Mar 11, 2005 at 03:17 UTC ( [id://438518]=note: print w/replies, xml ) Need Help??


in reply to Re: Near-free function currying in Perl
in thread Near-free function currying in Perl

Finally, AutoCurry has hit CPAN. Sorry it took so long.

Cheers,
Tom

  • Comment on Re^2: Near-free function currying in Perl

Replies are listed 'Best First'.
Re^3: Near-free function currying in Perl
by diotalevi (Canon) on Mar 20, 2005 at 22:56 UTC

    You have still neglected to leave the user with the ability to use a different suffix. This suffix is already used by Alzabo::MethodMaker (for row columns) though it is configurable. If I intended to use both Alzabo and AutoCurry, I'd have to do some fancy footwork with the symbol table to rename all the curried functions before other _c functions were installed (or is it the other way, I forget).

    Your accomodation may be as simple as providing an overridable package scalar.

    BEGIN { $AutoCurry::Suffix = '_not_c'; } use AutoCurry ':all';
      Thanks for the friendly reminder.

      I just uploaded version 0.1003 to CPAN. It includes the following addition:

      =head2 Using another suffix Do not change the suffix unless you truly must. If for some reason you cannot use the standard C<_c> suffix, you can override it by changing C<$AutoCurry::suffix> I<for the duration of your calls to AutoCurry>. Use C<do> and C<local> to limit the scope of your changes: use AutoCurry; # suffix changing is not compatible with ':all' my @curried_fns = do { local $AutoCurry::suffix = "_curry"; AutoCurry::curry_package(); }; # result: ( "main::foo_curry" ) sub foo { ... }; # foo_curry will be created by call to curry_package, above

      I cannot use the BEGIN approach that you suggested because that would override the suffix for all subsequent users of AutoCurry, not just the current package.

        Ok, here's the BEGIN approach changed so it *does* work for you. I'm just creating a use() which has the value set for its duration. Any later calls to use() or ->import() won't reflect the suffix I set here.

        BEGIN { local $AutoCurry::suffix = ...; require AutoCurry; AutoCurry->import(); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://438518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-25 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found