-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add spec URLs for javascript.operators.spread #17017
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
Conversation
|
Yes—these URLs are correct. MDN is (for good reason) merging three spread syntaxes into one, but using consistent terminology within the page (i.e. we are always clear if we are talking about array spreading, parameter spreading, or object spreading). Speaking of this, in Python the two "spread operators" are slightly different— a = { "foo": 1, "bar": 2 }
b = { **a, "baz": 3 }
a = [1, 2]
b = [*a, 3]
# args is an array and kwargs is a dict
def foo(*args, **kwargs):
passThat IMO is clearer from a language design perspective, and maybe makes those who dislike operator overloading happy :D |
|
We have three subitems here. The |
Yes, we should. If you have the spec URL at hand, that’d be great — I can add it on this PR branch |
|
Actually I think we should update the other two URLs as well! (Of course, every syntax-directed operation usually has two spec locations: one for the syntactical production which you found, one for the runtime semantics like https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-runtime-semantics-argumentlistevaluation. Do we have a convention to include both or only the syntactical production?) |
65b99d4 to
4fe6b7e
Compare
OK, please take a look now — I pushed an update to make it as described above. Note however that this leaves us with no spec URL for the Anyway, we have similar existing cases of that kind of thing — so my linter code has an allowlist that I can add this one to.
I think the (undocumented) convention we have effectively is that the links are to the syntactical productions, and not to the runtime semantics. I wish I could assert that more strongly, since I was actually the one who added almost all of them to BCD initially — but when I did the initial adding of them, it was based mostly on the spec URLs we had in the already been using in the existing Specifications sections in MDN articles. However, I recall doing some “normalizing” of them when I added them to BCD, and I think in part that might have involved choosing the productions rather than the runtime stuff. Regardless, considering it right now in terms of the developer audience we’re optimizing for in MDN — rather than the audience of runtime implementors or others — it seems like using the productions makes the most sense. That said, though, nothing about this is written in stone — so if you think we should be linking to the runtime semantics instead, we should discuss it more, and we could make changes. (It’d be a lot of changes of course — but if we ended up deciding that’s how we wanted to do it, it seems like we might be able to automate much of the changes, since the ES spec anchors follow a consistent pattern.) |
|
I don't have strong feelings. If you ask me then linking to runtime semantics is my call—since the behavior is usually more interesting than the syntax (which should hopefully be straightforward!) Also, it's relatively easier to jump from runtime semantics to the corresponding production than the other way round (I would consider that a defect of ecmarkup itself, though). I've constantly finding myself scrolling through pages just to get to the runtime semantics of a certain production (especially in the expressions section) since they are not closely collocated. But to tell you the truth, I don't think there's a consistent pattern to do the |
queengooborg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I trust your judgement for spec URLs, @sideshowbarker, and yours on JavaScript, @Josh-Cena!
@Josh-Cena This one could really use some review and guidance from you. Of the three ES spec URLs this change adds, I’m not 100% convinced that any of them are what we need here. The first one,
#prod-SpreadElement, seems like the one most likely correct — but I’m less sure about the#prod-ArgumentListone, and even less sure about the#prod-PropertyDefinitionone.In general I have only a vague understanding of the formalism that the ES spec uses, and how it translates to the syntax in JavaScript code. But I found https://stackoverflow.com/a/37152508/441757 helpful in trying to connect the dots a bit more. However, that’s also made me realize I’m not sure exactly what “spread syntax” — or more like, which spread syntaxes — our article at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax is meant to be scoped to (and thus also what we should be scoping this BCD entry to).