The readme gives as the sole motivation for this proposal the desire to be defensive against mutation of Function.prototype
.
I don't find this motivation nearly compelling enough to justify new syntax. If you want to run in an untrusted environment already need to be saving any other prototype methods, as the readme notes, even given this syntax:
// Our own trusted code, running before any adversary. const { slice } = Array.prototype;
Once you're doing that, the additional overhead of saving the various Function.prototype
methods is negligible. That is, code which wants to be defensive can (and indeed generally does) already write
const { bind, call } = Function.prototype; const uncurryThis = bind.bind(call); const slice = uncurryThis(Array.prototype.slice); // [...] delete Array.prototype.slice; delete Function.prototype.call; // [...] slice([0, 1, 2], 1, 2); // works fine
So it seems to me that this syntax does relatively little to improve this relatively obscure use case. As such, it doesn't seem to me to even approach the bar for adding new syntax, at least not on the strength of the motivations given in the readme. Are there other motivations?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4