-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open Question: what happens with a missing intrinsic? #6
Comments
I'd vote |
How would a user differentiate |
I'm not sure I understand how the implementation would know that a thing is a specified thing that it just hasn't implemented yet. |
Ha, that’s a fair point. |
Ok thinking about this more, there is actually a very valid reason to not return |
It's technically the case for every setter in the language :-) This would be a problem for any sentinel value, unless we use a container, which has poor ergonomics. |
Fair.
Is there actually any exposed as an intrinsic value? Agreed a container is terrible ergonomics, but having to wrap in try catch isn't particularly great either. |
Any what, |
I'd want to throw a |
|
Indeed; every infinite possibility is potentially “not implemented yet”, so when it isn’t providing the expected intrinsic, it can only do one thing: throw, or return a sentinel. |
Pretty straight forward on how to do that. The spec exists, right? If a version of an ES engine conforms to a given spec, then it should have every required capability of that spec. The developers of that engine would then be responsible for tracking the unimplemented portions of the spec and coding accordingly. It's not that the engine would calculate this, but rather that this would be hard coded in the engine. |
That just triggered a new thought. Maybe there should also be an API for retrieving the ES spec version that the engine supposedly conforms to. |
Do you mean that an engine has to decide it implements a specific spec version and stick to it strictly? How would it implement stage 3 proposals in that case? |
The implementation can’t know what will be added to the spec tomorrow, and the spec does not actually exist from a runtime perspective. If the engine knows about something, it implements it. |
Engines do not, and will never, strictly strictly adhere to any “version” of the spec, nor is there any such version - it’s a living standard, and the latest version is whatever is on the default branch on GitHub. The yearly editions are merely snapshots. |
What I mean is that an engine can conform to ES6, while still implementing ES7 features. If the requested intrinsic is an ES6 feature, but that feature is not available, @ljharb I get that the spec is a "living standard". However, that "living standard" changes in surges and gets labelled when it does: ES3, ES5, ES6, ES2015, ES2017, etc.... Whether you want to call it that or not, that's versioning. Pair that with a date code, and you'll know the state of the specification that a given engine is trying to conform to. Isn't the spec document in a GIT repo? Again versioning. I'm just saying make use of it. It's a piece of meta information that would be useful to developers. |
Engines don’t claim to, nor actually, conform to a specific version of the spec, and never have. Engines would never agree to this requirement - it’s a nonstarter. If an intrinsic isn’t present, whether because it’s not standardized yet or not implemented yet, it must only behave one way. This issue is about which way that will be. |
Unfortunate. Oh well. Under those restrictions, seems |
I think a sentinel would be my preferred option, such as a new well-known symbol |
@JakeChampion then what happens with |
Since we might need an enumeration style API, would it make sense to structure |
@mhofman I very much do not think we might ever need an enumeration style API, and this proposal explicitly is not providing one (and i suspect @erights would block it if it provided one). Since |
Let's discuss the enumeration need separately, I may have a use case that requires something like it. Need for enumeration aside, I wasn't thinking of a |
That’s a pretty big new primitive (in the language sense) to design, when a) all the current use cases only require getting a single known intrinsic, and b) an enumeration use case would probably merit an iterator rather than a large in-memory construct. |
I'm curious as to why it has to be a new primitive when a frozen object satisfies the described requirement fully? Isn't |
@rdking that's a fair point, that it'd make more sense as a null object. but that still would require a large observable in-memory object, which none of the motivating use cases require. |
There's also the problem that one would need to capture |
When the argument to
getIntrinsic
does not result in a result being returned, what should it do?Options:
undefined
TypeError
if we're boring,SyntaxError
if we're whimsical, etc)The text was updated successfully, but these errors were encountered: