Function constants for Identity and No-op

Kevin Reid kpreid at
Wed Aug 10 16:24:19 UTC 2016

[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: = function (f) {
    if (f === Function.IDENTITY) {
        return this;
    } a new collection with f applied to elements and return it...

Of course, it would be silly to write, 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.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list