Andreas Rossberg (2015-06-30T13:55:29.000Z)
On 30 June 2015 at 15:39, Jonathan Bond-Caron <jbondc at gdesolutions.com>
wrote:

> On Fri Jun 26 05:23 PM, Brian Terlson wrote:
> > https://github.com/tc39/tc39-notes/blob/master/es6/2015-05/may-29.md
>
> Yay to Value types
> and +1 for the per-realm thinking
>
> For typeof, this would seem intuitive:
>
> var ColorType1 = ValueType(Symbol("Color"), {...});
> var ColorType2 = ValueType(Symbol("Color"), {...});
> var ColorType3 = ValueType(Symbol("Other"), {...});
> var ColorType4 = ValueType(Symbol(), {...});
>
> typeof ColorType1 // "Color:s1" // where s1...sN is a generated
> increment/key for a new user symbol
> typeof ColorType2 // "Color:s2"
> typeof ColorType3 // "Other:s3"
> typeof ColorType4 // "s4"
>

A seemingly predictable name is a rather bad idea, because it would be very
brittle, e.g., depend on other libraries loaded, or even loading order.
It's better to have clearly non-deterministic (e.g. gensym) than something
that pretends to be deterministic but isn't in practice.

In fact, it might be best if typeof returned the symbol itself. At least
that cleanly matches the generative nature of the type definition. If you
want it to work cross-realm, you have to broker the symbol as usual.

/Andreas

// Global symbols use their keys prefixed by a 'g'
> var ColorType5 = ValueType(Symbol.for("Color"), {...});
> typeof ColorType5 // "gColor"
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150630/04ceae33/attachment.html>
d at domenic.me (2015-07-07T02:12:23.337Z)
On 30 June 2015 at 15:39, Jonathan Bond-Caron <jbondc at gdesolutions.com>
 wrote:

> For typeof, this would seem intuitive:

A seemingly predictable name is a rather bad idea, because it would be very
brittle, e.g., depend on other libraries loaded, or even loading order.
It's better to have clearly non-deterministic (e.g. gensym) than something
that pretends to be deterministic but isn't in practice.

In fact, it might be best if typeof returned the symbol itself. At least
that cleanly matches the generative nature of the type definition. If you
want it to work cross-realm, you have to broker the symbol as usual.