On May 31, 2012, at 2:40 PM, Mark S. Miller wrote:

> I think there's a core confusion at the heart of this thread. Let's restart 
> operationally. 
> 
> If one did have such a predicate, when would some other program actually use 
> it? In other words, for the predicate you have in mind, please give a 
> concrete example where a program would usefully say
> 
>     if (isBoundOrWhateverWeCallIt(f)) {
>         //... do something
>     } else {
>         //... do something else
>     }
> 
> If the predicate means what I think it should mean, I can offer some examples 
> of when I would do this. If the predicate means anything else that's been 
> advocated on this thread, such as "fat arrow or bound", then I have no idea 
> why anyone would ever write code as above. Can anyone offer a concrete 
> example? If not, then I suggest that these other proposed meanings are simply 
> not useful.

For example, somebody might want to replace the existing apply, call, and bind 
methods, with versions that throw an error when invoked on a fat arrow or bound 
function.  For example:

(function replaceCall() {
   if (Function.prototype.hasOwnProperty("intrinsicCall")) return;
   Object.defineProperty(Function.prototype,"intrinsicCall", {value: 
Function.prototype.call, configurable:true});
   Function.prototype.call = function(...args) {
       if (this.isBound()) throw new TypeError("Using call method with a bound 
function");
       else return this.intrinsicCall(...args);
    };
})();

This would seem useful for testing to see if any "bound functions" are being 
used in situations that may be trying to explicitly provide a this value.

Allen







> _______________________________________________
> 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