new instantiation design alternatives

Domenic Denicola domenic at domenicdenicola.com
Fri Sep 19 15:41:46 PDT 2014


Heh, we've gone around in circles.

Remember that the original motivating reason for @@create was to separate allocation and instantiation, in reaction to implementers saying that it would be madness for you to be able to do

```js
var o = {};
Map.call(o);
Set.call(o);
WeakMap.call(o);
Uint8Array.call(o);
// ...
```

and get a hybrid map/set/weakmap/byte array/etc. (If you look through older drafts, before @@create, you'll find that this was at the time possible.)

The argument is that each of these requires an exotic type of object with a different backing implementation, and no single object should have more than one backing type.

So,

> What if I wanted a Uint8Array that incorporated behavior from some other class (which required initialization logic)?

is essentially an explicit *anti*-goal of the ES6 object-construction design journey.


More information about the es-discuss mailing list