On Oct 14, 2011, at 10:45 AM, John J Barton wrote:

> On Fri, Oct 14, 2011 at 12:56 AM, Jake Verbaten <rayn...@gmail.com> wrote:
> The difference is that object.extend returns objects where as object.make 
> returns things with the same type as the second operand.
> 
> So object.extend (obj, someFunction) is easy.
> 
> where as object.make(obj, someFunction) returns a function. Now clearly its a 
> new function so it doesnt share closure state. But then how can you say the 
> returned function is the same as someFunction?
> 
> Sorry I don't understand. I can't imagine any way that object.make() will 
> return its second argument and that is the only way the returned function 
> would be the same as the second argument.

Yikes, ambiguous language.

Jake clearly meant "same" as in "twin" or "clone". You are the one advocating 
functional purity -- fresh objects, no observable mutation. For Object.make to 
be like <| this means the result is not a clone of the first argument, rather 
of the second.

But then Jake's point about closures becomes crucial. Does the function and its 
environment get cloned? Closure environments contain mutable bindings.

This is just one of many "edge cases" already mentioned that plague attempts to 
define cloning such that you get the "same" kind of object as the second 
parameter, a twin or clone.

So for the path you are advocating, pure functions that make fresh objects, you 
need to specify cloning. That is a tall order. And it's not obviously needed, 
since the de-facto standard that <| is codifying and constraining is the 
preset-__proto__ use case. There's no common clone pattern in the field, AFAIK.


>  This is just one of the edge cases. I would love an object.make as well. But 
> I cant tell you how to handle all the edgecases.
> 
> 
>  
> The only open question about Object.make(obj, someFunction) that goes beyond 
> the questions for the protoLink operator <| relates to the difference between 
> someFunction and a literal function declaration.

This sounds like vehement agreement, but you didn't say what that open question 
is. It's exactly the "cloning" question.

/be

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to