-
Notifications
You must be signed in to change notification settings - Fork 7
reconciling the disparate function implementation hiding use cases #23
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
We never did document this case very well. In particular, I am curious as to whether this can apply to "public" functions, or only to functions that are called by other "public" functions. I say this because there are also encapsulation/polyfilling cases where this makes sense, but they have that public/private divide. E.g., using your names, Array.prototype.somethingCool = function () {
"polyfill";
return someHelper(this);
};
function someHelper(arr) {
"sensitive implementation";
// ...
}
I don't quite understand how you are using the term here.
I agree with the overall outcomes, although per my above example, I think the names probably need tweaking. (Maybe "internals hidden" vs. "completely hidden" is a theme to think about.) I think we may be coming up against a complexity budget; folks were already hesitant about one new directive, and two may be stretching it. I'm wondering if there are other tweaks to the "API" we could make to improve that. Or at least we could present some creative alternatives to the committee, if only to show that two directives is the simplest path. As a handwavey and imprecise example, we could contemplate something like a single module- or class-level directive that has the combined effects of:
|
The committee went with our recommendation: https://docs.google.com/presentation/d/1lWH97DxTLU3_1EJA-F19uIzagZQx7PZmys7WyNXw3cY/edit#slide=id.g5ded237d17_0_65
For now, we also have |
In the previous TC39 meeting, we discovered that there are a number of use cases for "function implementation hiding", and they have some overlapping and some conflicting requirements. Here is my attempt to categorise these requirements so we can decide how we would like to move forward with the proposal more concretely.
Use Cases and Their Requirements
Under each use case for "function implementation hiding", I've listed the individual requirements needed to accomplish the use case's goals.
a. the function does not appear in stack traces
b. the function's source text (including parameter list) is not available through F.p.toString
a. the function does appear in stack traces
b. the function has no file attribution or position info in stack traces
c. the function is rendered as a
NativeFunction
by F.p.toStringa. the function does appear in stack traces
b. the function has no file attribution or position info in stack traces
c. the function's source text (including name and parameter list) is not available through F.p.toString
d. the function's
length
property is not necessarily based on its parameter liste. the function's
name
property is not necessarily based on the syntactic bindinga. the function does not appear in stack traces
Features
A grouping of the requirements such that they can be composed to satisfy each use case produces the following "features":
NativeFunction
by F.p.toString (satisfying 1b, 2c, 3c)length
property is not necessarily based on its parameter list (satisfying 3d)name
property is not necessarily based on the syntactic binding (satisfying 3e)Notes:
Object.defineProperty
to override thelength
andname
assigned to the function at creation. This can be made into a function/decorator for ease of use in expression position.Alignment of Use Cases with Features
The minimum features to accomplish each use case:
Options
Assuming I've done everything right up to this point, we need to make the following choices:
My preferences:
"sensitive implementation"
?)"polyfill"
?)The reason I've chosen a directive for A and B together instead of keeping them distinct is the desire to have a single opt-in for the security use case, as I described in #8. I am not very opinionated on the polyfilling use case, so I could go either way on the directive for Feature B. Feature C does not seem to pay for itself, since it has good alternatives today.
The text was updated successfully, but these errors were encountered: