Kevin that "from somewhere else" has same problems cross-realm `instanceof`
would have, you can't always trust that and if you want to map identities
just do it instead of adding extra code ;-)

On Wed, Aug 10, 2016 at 5:24 PM, Kevin Reid <[email protected]> wrote:

> [no quotes because I'm not replying to anyone in particular]
>
> An advantage that has not been mentioned yet, of having a canonical
> function instance for particular behaviors, is that it allows for some
> library-level optimization by being able to know what a function does
> (which is otherwise opaque). For a simple example:
>
> SomeKindOfImmutableCollection.prototype.map = function (f) {
>     if (f === Function.IDENTITY) {
>         return this;
>     }
>     ...build a new collection with f applied to elements and return it...
> };
>
> Of course, it would be silly to write coll.map(Function.IDENTITY), but a
> caller might be passing the function from somewhere else.
>
> (I only intend to point out this one benefit, not to claim it justifies
> the feature entirely.)
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to