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

Should "show source" be part of this proposal? #42

Open tmikov opened 4 years ago

tmikov commented 4 years ago

Hermes (and probably Moddable, QuickJS, etc?) doesn't preserve the source by default since everything is compiled to bytecode in advance. In other words "hide source" is the default. It seems that such implementations are becoming more widespread recently.

So, in Hermes we are planning to add a "show source" (or "preserve source", etc) directive for the few cases where the source must be available at runtime.

The question is, does it make sense to consider adding it to this proposal, since it is technically relevant?

michaelficarra commented 4 years ago

@tmikov Did you see https://github.com/tc39/proposal-function-implementation-hiding#why-is-there-no-preserve-source-directive?

tmikov commented 4 years ago

I did, but I don't think it fully addresses this use case. In several implementations like Hermes the source is simply not available by default. At the same time, there are legitimate situations where the source of a selected few functions is needed at runtime.

So, implementations have to come up with custom and potentially differing solutions for this. That is fine, or perhaps a new and separate proposal is the best way to address this. But given how closely related it would to the this current proposal, I thought it makes sense to bring it up. In some sense it would be strange to have one proposal adding "hide source" and a second one adding "show source" :-)

tmikov commented 4 years ago

To be clear, I am not insisting that this be included, but I feel that it is a more common use case than is commonly assumed, so I am just testing the water what people think. As I understand it, since we are not at stage 3 yet, this is the last opportunity to do it.

michaelficarra commented 4 years ago

@tmikov Implementations are allowed to have their own implementation-defined directives. Hemes can add such a directive, as long as it is not in violation of the spec (not that they care about conformance, apparently). So, for example, they could have a "show source" directive that would preserve the source text except where it would otherwise be explicitly hidden using "hide source".

tmikov commented 4 years ago

@michaelficarra for the record, we do care about conformance a lot. That is precisely why I am filing this question and why we are attending TC39 meetings. My point is that there are currently multiple engines running from bytecode with this same issue and they seem to be gaining popularity outside of web. However the use case may not be as visible to people focusing on web or they may (incorrectly) assume that those engine don't care about spec conformance.

I think it would be a disappointing if every such engine implemented a different solution to this when we have a chance to unify it.

linonetwo commented 8 months ago

I'm using 'show source'

Related https://github.com/facebook/hermes/issues/114#issuecomment-887106990