One possibility is to make type() work for all values:
switch(type(x)) {
case Primitive.null:
...
break;
case Primitive.string:
...
break;
case String:
...
break;
}
That is, it would map primitive values to Primitive.* constants (or something
similar, e.g. from a reflection API) and objects o to o.constructor.
On May 8, 2012, at 23:45 , David Herman wrote:
> On May 8, 2012, at 9:19 AM, Rick Waldron wrote:
>
>> non-strict, non-opt-in:
>>
>> typeof null === "null"; // false
>>
>> implied opt-in:
>
> Changing typeof null always seemed questionable to me in terms of value. It
> doesn't really give you significant new functionality, it just kinda seems
> "more sensible". But adding it would just make things *more* messy, for very
> little gain. Since we can't eliminate the old typeof semantics, we end up
> with the language having different semantics in different contexts.
>
> And then once we moved to 1JS, it just seemed that much worse to have the
> variability, since the exact same code can have different meanings right near
> each other:
>
> var x = typeof null;
> module Foo {
> export var y = typeof null;
> }
> console.log(x) // "object"
> console.log(Foo.y) // "null"
>
> It's just not worth it.
>
> OTOH, we could pretty easily add a new library function:
>
> import type from "@std";
> console.log(type(null)) // "null"
>
> I'd support that.
>
> Dave
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss