I like the idea of Function.prototype.curry. It goes hand-in-hand
with Enumerable and is useful for stuff like argument rearranging.
I feel like Function.prototype.rcurry is an edge case, but I might be
in the minority there.
While we're on the subject, I proposed Function.prototype.defer in
Campfire last week, so that instead of...
window.setTimeout(Foo.bar.bind(Foo, "baz", "thud"), 1000);
...you can do...
Foo.bar.defer(1000, "baz", "thud");
Feels more OOP. Plus it'd correct scope automatically.
Anyone else have opinions on any of these?
Cheers,
Andrew
On Apr 9, 11:21 am, Michael Peters <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > curry. Curries (binds an argument to) a function or method.
> > Preserves this if it is bound.
>
> > ltrim = String.prototype.replace.curry(/^\s*/,'');
> > ' hello'.ltrim(); // => 'hello'
>
> > rcurry. Curries an argument to the end (instead of the beginning) of
> > the argument list. Useful for binding arguments for things like event
> > handlers, where the initial argument is always the event.
>
> I know I don't really get a vote on these things :), but I'd love to see these
> in Prototype. There are so many times that I want to pass a function as a
> callback with 1 arg and doing
>
> function() { other_func(arg) }
>
> just looks ugly.
>
> --
> Michael Peters
> Developer
> Plus Three, LP
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---