<| with function RHS is brittle

Herby Vojčík herby at mailbox.sk
Sun Mar 4 13:59:58 PST 2012


Hello,

I feel uneasy about this in <| proposal:

> If the LHS operand has a property named prototype and the RHS
> operand is a function expression then the [[Prototype]] of the
> function object is set to the LHS object and the prototype property
> of the new function is set to a new object whose [[Prototype]] is the
> value of the LHS’s prototype property.

It looks a little "perlish" to me, in the sense that when you write

   x <| function (...) {...}

you must guard what x is because you can get two different outcomes
(same as perl can use element in place of container, which backfires if
the element itself is a container). I think it should be rephrased as:

> If the RHS operand is a function expression then
>   a. if the LHS operand has a property named prototype the
> [[Prototype]] of the function object is set to the LHS object and the
> prototype property of the new function is set to a new object whose
> [[Prototype]] is the value of the LHS’s prototype property.
>   b. otherwise TypeError exception is thrown.

Herby


More information about the es-discuss mailing list