Jordan Harband (2015-02-22T23:18:27.000Z)
I'd love to bring a proposal to the committee for this since it seems like
there's interest.

I suspect that even though some of the "empties" seem useless to some,
somebody somewhere will find a use case, and consistency is useful (that
everything that could have a concept of "empty" would have a .empty)

Errata:
 - I don't believe `GeneratorFunction` is a global, so we wouldn't need to
specify one of those
 - I wonder if `Promise.empty` as `new Promise()`, ie, a forever pending
promise, would make sense?
 - or `Date.empty` as `new Date(0)`?
 - We'd definitely want `Map.empty` and `Set.empty` assuming
`Object.freeze` actually froze them
 - We'd probably want
`Object.freeze(Object.seal(Object.preventExtensions(empty)))`, to be extra
restrictive.

Does anyone see any problems or have any objections, beyond "I don't think
there's a use case"?

On Sun, Feb 22, 2015 at 2:58 PM, Isiah Meadows <isiahmeadows at gmail.com>
wrote:

> I really liked Jordan Harband's suggestion
> <https://esdiscuss.org/topic/array-prototype-change-was-tostringtag-spoofing-for-null-and-undefined#content-12> of
> adding Array.empty, Function.empty, etc. to ES7. It is relatively easy to
> polyfill as well.
>
> ```js
> [Array,
>  ArrayBuffer,
>  Int8Array,
>  Int16Array,
>  Int32Array,
>  Uint8Array,
>  Uint8ClampedArray,
>  Uint16Array,
>  Uint32Array,
>  Float32Array,
>  Float64Array]
> .map(T => [T, new T(0)])
> .concat([
>   [Object, {}],
>   [String, ''],
>   [RegExp, /(?:)/],
>   [Function, function () {}],
>   [GeneratorFunction, function* () {}]
> ])
> .forEach(([root, empty]) =>
>   Object.defineProperty(root, 'empty', {
>     value: Object.freeze(empty),
>     configurable: true,
>     enumerable: false,
>     writable: false
>   }));
> ```
>
> The code effectively explains what I think would make suitable
> replacements for each. I don't see the use cases for some of these, though,
> such as `String.empty` or `RegExp.empty`.
>
> --
> Isiah Meadows
>
> _______________________________________________
> 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/20150222/c1ae4667/attachment.html>
d at domenic.me (2015-03-06T00:39:50.814Z)
I'd love to bring a proposal to the committee for this since it seems like
there's interest.

I suspect that even though some of the "empties" seem useless to some,
somebody somewhere will find a use case, and consistency is useful (that
everything that could have a concept of "empty" would have a .empty)

Errata:
 - I don't believe `GeneratorFunction` is a global, so we wouldn't need to
specify one of those
 - I wonder if `Promise.empty` as `new Promise()`, ie, a forever pending
promise, would make sense?
 - or `Date.empty` as `new Date(0)`?
 - We'd definitely want `Map.empty` and `Set.empty` assuming
`Object.freeze` actually froze them
 - We'd probably want
`Object.freeze(Object.seal(Object.preventExtensions(empty)))`, to be extra
restrictive.

Does anyone see any problems or have any objections, beyond "I don't think
there's a use case"?