On Oct 2, 2011, at 8:19 PM, Allen Wirfs-Brock <al...@wirfs-brock.com> wrote:

> 
> On Oct 2, 2011, at 5:02 PM, Russell Leggett wrote:
> 
>> On Oct 2, 2011, at 6:19 PM, Allen Wirfs-Brock <al...@wirfs-brock.com> wrote:
>> 
>>>> 
>>> 
>>> Is that the
>>>  SuperClass <| {    
>>>     ...     
>>>     }
>>> part evaluates to the prototype object, not the constructor function and 
>>> hence what you would be naming is the prototype.  This, in general, is how 
>>> stache has to work for arbitrary object literals where all you really are 
>>> trying to do is set the [[Prototype]].  There really isn't anything special 
>>> in your pattern that distinguishes it from that simple object case.
>> 
>> What distinguishes it is that I was adding a new case to <| operator where 
>> the LHS is a constructor function and the RHS is an object literal. My 
>> intention was that SuperClass would be the constructor function not a 
>> prototype. Perhaps this is confusing because the return type is not the same 
>> as the same as the RHS.
> 
> Ok, your intent didn't come across.  
> 

This is what I wrote to Axel to explain:

> 1. If a "constructor" method is supplied as part of the object
> literal, it will be used as the new constructor, and take the LHS
> constructor as its prototype. If not, an new empty constructor will be
> created instead and take the LHS constructor as its prototype.
> 2. The rest of the object literal will be used as the new constructors
> prototype, and it will use the LHS's prototype as it's prototype.
> 3. The result of the <| operand in my example would be the new
> class/constructor function, so it can be assigned to "const ClassName"
> or as in my example, the .{ operator can be used to add class methods
> and still return the correct result.


> What happens if the RHS does't have a 'constructor' property?  For example:
>     let obj = function() {} <| {};
> 
> Would obj be a function object?  If so, what is it's body.


obj would indeed be a constructor function and would basically be equivalent to
    let obj = function(){} <| function(){};

> Is it the existence of a 'constructor' property in the LHS object literal 
> that triggers the creation of a function object instead of a non-function? 

I'm guessing you meant RHS, but no, I don't think that should be necessary. I 
think all that would be needed would be a function on the LHS, and an object 
literal on the RHS.

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

Reply via email to