typed objects and value types

Andreas Rossberg rossberg at google.com
Wed Apr 2 22:33:48 PDT 2014

On 2 April 2014 19:37, Niko Matsakis <niko at alum.mit.edu> wrote:
> Along those lines, user-defined values (uvalues) probably ought to
> have the following characteristics:
> - uvalues are (shallowly) immutable
> - uvalues have no "generative identity", and are compared using "by-value" ===
> - uvalues have a prototype linked to their def'n
>   - the syntax 'uvalue.foo' can be used to access members of this prototype
>   - when transmitted between realms, uvalues retain this link
> - uvalues cannot go into weak maps, but can go into other maps/sets
> Does this sound about right?

It does.

> Clearly I left open the question of what typeof yields (which I don't
> feel *especially* strongly about, actually, I don't have much intution
> for what `typeof` *means* to people) and whether `uvalue.foo` works
> via a wrapper or some other mechanism.

Yes, I understand. I agree that typeof is a somewhat dubious feature.
However, there are certain invariants that people seem to rely on
regarding typeof, e.g. that testing for type 'function' identifies
callables, Not sure what type 'object' is used for in the wild.

I also remember one TC39 discussion from 1+ year ago where we
concluded that new future types like int64 should have their own
typeof result.


More information about the es-discuss mailing list