-
Notifications
You must be signed in to change notification settings - Fork 108
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
Prohibiting whitespace after @
#430
Comments
What you refer to as "discarded tokens" aren't tokens, though they are input elements.
I believe the latter 2 uses of "production" are mis-uses. E.g., for
Because neither is a production, they are grammar symbols. |
@jmdyck: You’re right regarding both “tokens” versus “input elements”, as well as “productions” versus “grammar symbols”. (And I meant for the symbol “immediately preceding the indicated position” to be This might be a moot point anyway. @bakkot left a comment in tc39/ecmarkup#356 (comment) about an alternate approach for decorators (as well as for
|
I'm not convinced that They are different from private names, where you can never see the name without |
@nicolo-ribaudo: Does that mean you think that there should be whitespace allowed between |
Oh I forgot to reply. I think we should permit a space between
It's even more clear that @foo.bar
class A {} First you evaluate I think the whitespace here is just a stylistic choice and in practice almost no one will write it, similarly to how almost no one writes |
To me, it makes it feel like it has higher importance, which it does :-) In practice, everything where there's a stylistic choice either ends up in one of three places:
The fourth option is "the language selects one, nobody has any choice, and nobody has to spend time or effort deciding on one". JS has traditionally not selected this option, but that doesn't mean it wouldn't have been, and isn't still, the better choice. I hope we break with tradition and make the better choice for decorators, avoiding a whole bucket of timelines full of style debates. |
No, there's also "everyone agrees on one idiom immediately". For example, it is possible to put two spaces between the Conversely, having the language impose such arbitrary restrictions has real cost for tooling, and can limit flexibility in annoying ways. The language is not the right place to impose stylistic preferences. |
What cost for tooling? parser complexity? |
Parser complexity is a small part, yes, but it also means that, for example, there are more incorrect-formatted programs which Prettier will reject outright instead of being able to clean up (unless they implement and use a parser with error recovery, which is hard to do right and requires even more work), and code generators need to know they can't insert a space there (which is annoying if, e.g., your code generator tries to avoid outputting strings which look like email addresses), and so on. |
Just found this issue :) I asked the question in the discussion of hack-style topic token one hour ago, and I strongly prefer prohibit whitespaces after |
We discussed this at plenary, and decided that it did not make sense to fully restrict whitespace after the |
Allowing whitespace between the |
More specifically, allowing whitespace after I don’t think it would be fatal if We would just keep parsing |
@js-choi How does the space make a difference? If |
@nicolo-ribaudo: The idea would be that Having said that, I personally think both In any case, though, I don’t think it’s a big problem for |
From UX perspective, if we have both topic ref and decorators, we should make the syntax easy to differentiate. Even parsers can differ them with special rules (still very hard), it's too hard for average programmers to understand the rules and eye parse the code. Note, in current Similarly I suggest we also change the escape hatch syntax to Disallowing whitespace after |
Spinning this off from a discussion on Matrix TC39 General (cc @jmdyck, @ljharb, @tabatkins):
The proposal’s specification has the following productions:
@
DecoratorMemberExpression@
DecoratorCallExpressionThese currently seem to allow whitespace after
@
, so that the following are allowed:This is probably undesirable. The
@
is “clearly” part of the identifier. If any developer wants the decorator expression on a new line, they could use@()
.So what we could do is define a new syntactic annotation “[contiguous]” in the Syntactic Grammar clause:
…and redefine those productions as:
@
[contiguous] DecoratorMemberExpression@
[contiguous] DecoratorCallExpressionThe Hack-pipes proposal will probably use such a “[contiguous]” annotation too for its own purposes (see tc39/proposal-hack-pipes#13 (comment)).The text was updated successfully, but these errors were encountered: