You're right. I was speaking conceptually, I guess, and somewhat
vaguely. Let me try again. :-)
Technically, there is no question that:
f.compose(g) == compose(f,g)
which should mean "f composed with g", i.e., the function
f( g(x) )
The bind / compose example though is compelling exactly because I
expect:
f.bind(h).compose(g) == f.compose(g).bind(h)
which holds true in the current implementation. The reason is that the
use case that comes up is that the bind and compose events are
typically happening at different points in program execution and you
don't want to worry about the order they happen in.
A concrete example is maybe useful. Consider the following (from
Firebug):
>>> sort = Array.prototype.sort
sort()
>>> split = String.prototype.split.curry(' ')
function()
>>> split.bind('c b a').compose( sort )()
["a", "b", "c"]
>>> split.compose( sort ).bind('c b a')()
["a", "b", "c"]
It's mathematically WRONG, but very handy. Or maybe it's just me? :-)
BTW, it is exactly this kind of confusion that lead me down the path
of introducing a specific class called Method to handle bringing
together the OOP and FP worlds. Since a Method instance is an object
(not a closure), you can bind and curry all day and you are still
operating on the Method instance. And since I invented it, I don't
have to worry about it being mathematically incorrect! :-)
Dan
On Apr 23, 6:24 am, "Ryan Gahl" <[EMAIL PROTECTED]> wrote:
> > I think I am
> > still expecting the bind operation to be applied to the subject of
> > this "sentence", that is, function a, not b."
>
> I would expect the bind to apply to whatever the result is of the compose
> (or any other) method, not the object to which the method belongs. In your
> example you are implying that the
> result of a.compose(b) is a function, which you are then binding c to. That
> makes sense, but not what you said. If you wanted c bound to a and then
> composed with b you'd need "a.bind(c).compose(b)"
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---