Some Typed Objects Confusion

David Herman dherman at mozilla.com
Wed Aug 21 17:02:40 PDT 2013


On Aug 21, 2013, at 2:36 PM, Brendan Eich <brendan at mozilla.com> wrote:

> David Herman wrote:
>> Any, String and Object should still be uppercase. The naming convention is: value types lowercase, reference types uppercase.
> 
> Is String really a reference type? Currently you can't tell, and JS docs and books don't (AFAIK) say "reference type" apart from object (not null; including function). String also happens to spell the constructor/converter function, which sadly both returns a primitive and creates a String object depending on how it is called.

You can tell, in that a type that includes String must be opaque. The might-be-a-pointer property of a type is observable in the typed objects API in that it cannot expose its backing storage as an ArrayBuffer. Strings necessarily might-be-a-pointer.

I take your point that it's confusing on the primitive/object axis, though.

So... all right, let's break out those paintbrushes. Let's say we use the lowercase naming convention for purely immutable types, independent of whether they might-be-a-pointer. This still leaves Dmitry's question about the unfortunate name collision -- even though modules make this "okay," it's still a PITA in practice not to be able to import Object without shadowing the built-in Object.

Personally I'd be fine with just lowercasing all the things. Brendan, you cared about using capitalization for object types, though. What color is your bikeshed?

Dave



More information about the es-discuss mailing list