Observing whether a function is strict
claude.pache at gmail.com
Thu May 26 14:03:55 UTC 2016
> Le 26 mai 2016 à 13:23, Mark S. Miller <erights at google.com> a écrit :
> On Thu, May 26, 2016 at 11:25 AM, Claude Pache <claude.pache at gmail.com <mailto:claude.pache at gmail.com>> wrote:
> > Le 26 mai 2016 à 10:43, G. Kay Lee <balancetraveller+es-discuss at gmail.com <mailto:balancetraveller%2Bes-discuss at gmail.com>> a écrit :
> > I was under the impression that strict mode is a (temporary) workaround to get rid of unwanted bad parts of the language without instantly breaking anything. The long term question thus should be: do we have a timeline on the final removal of non-strict behavior from the language, and establish the "strict mode" as the one and only standard behavior. If so, then introducing any additional language feature to help detecting strict/non-strict is certainly not ideal.
> AFAIK, there is no plan to remove non-strict mode.
> And to be clear about my intentions, what I have in the back of my head was certainly not "introducing any additional language feature to help detecting strict/non-strict" (yuck!), but whether it makes sense to think about a possible way to remove that leak from `Function#arguments` and `Function#caller`. But it would be premature to consider that issue without *at least* an answer to my original question: Are there other ways...?
> Hi Claude, what do you mean by "remove that leak"? Hypothetically, let's say you had such a test and that it was reliable. How would you use it remove the leak? (This is probably also the best way to clarify what precisely you mean by removing the leak.)
Maybe that "leak", namely observing whether a function is strict, is not something to care about.
But here is what I think to be a possible way to remove it: Because `Function#arguments` and `Function#caller` do return `null` for sloppy functions in some circumstances (namely, when the function is not found in the call stack), let them always return `null` for non-sloppy functions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss