tc39 / proposal-function-implementation-hiding

JavaScript language proposal: function implementation hiding
https://ci.tc39.es/preview/tc39/ecma262/pull/1739
MIT License
98 stars 7 forks source link

Explain why we think this won't become boilerplate in every source file #10

Closed domenic closed 5 years ago

domenic commented 6 years ago

Namely, that this is purely about encapsulation, and if it became e.g. a memory win, we'd immediately implement a different (out of band) app-wide mechanism.

dead-claudia commented 6 years ago

For it being potentially a memory win, there are two engines targeting IoT who already censor Function.prototype.toString globally for memory reasons: Moddable's XS (doesn't support eval either) and JerryScript (ES5 only). So it might be worth actually adding an out-of-band mechanism for this regardless of whether to include it per-file.

(And no, I just stumbled across this issue this quickly by blind luck... 😄)

domenic commented 6 years ago

Yeah, that's a separate proposal that would build on the HostHasSourceTextAvailable. But, right now those engines don't need it, and browser JS engines don't have the engineering resources to make it work, so it's on pause.

dead-claudia commented 6 years ago

Okay. It was just a thought. My implication was that this would be "implementation-defined" rather than "host-defined", so engines have the choice, not the embedder (unless, of course, engines exposed that to the embedder).

domenic commented 5 years ago

I meant to send https://github.com/domenic/proposal-function-implementation-hiding/commit/510c44345808492f07f06adffa642940354d056d as a pull request, oops. It makes statements about encapsulation and uses the term "we" which I would feel better getting co-champion sign-off on.

@michaelficarra or others, please let me know if https://github.com/domenic/proposal-function-implementation-hiding/commit/510c44345808492f07f06adffa642940354d056d needs any tweaks.