Comments (9)
Thanks for your input here. I like that you are writing in with ideas for what would be good for JS as a whole--we need input from lots of JS programmers there, not just TC39 members.
My biggest concern with an existing token is ASI. If we use an existing token, users may be forced to use a semicolon before a decorated class declaraction when they wouldn't need one for an undecorated class declaration.
Secondarily, a new token can be especially evocative. You can make an association that @ means decorator. Overloading existing tokens makes this harder.
@ljharb previously proposed swapping @ and #. The committee did not accept the proposal at the time largely because many programmers are happy with @ in transpilers. Presumably, those programmers would not be so excited to switch to / or ^ either.
from proposal-decorators.
Template literals were added which use backticks, which are brand new tokens - your inference is incorrect; there's no resistance to adding new tokens nor any preference to prefer existing ones.
from proposal-decorators.
Iām confused; why would it be better to use a token with an existing meaning, rather than a new one?
from proposal-decorators.
@ljharb It seems that introducing new symbols (characters) for new functionality is something which is generaly discouraged in EcmaScript. Let's take a look at few examples. When generator functions as methods of object literal are introduced, their token was *
(they didn't use #
or @
, or Š
, or any illegal tokens, they used existing tokens which was illegal in that context until generator functions have been introduced). Another example: spread operator. They might use #
for spread operator, but no, they decided to use three consecutive dots, which had been illegal until that proposal. There are a lot more examples, like ([a])=>a
, or (a=b)=>a
, or tagged template literals, or similar. It seems that using old symbols with new meaning is prefered over introducing new symbols.
Symbols #
and @
were never a valid JavaScript tokens, and I don't see a reason to make them valid after this proposal. In my opinion, it would be much better to use, for example, &
and ^
respectively, as these tokens are currently invalid in such context. But, anyways, this is just my opinion, I suggested, but you decide.
from proposal-decorators.
It seems like the community really likes the proposed tokens @
and #
. Do you think it would be good to close this feature request, or which procedure is usually used in such situations? I mean, do we organize some poll or something similar, or, when the situation is clear (like in this case) we close feature request immediately?
It really isn't much important to me, I just thought that there was some sort of hindrance from introducing new tokens, but as explained above, there was not, so I think it would be good to decide what the community says.
Feel free to close this if you want.
from proposal-decorators.
Closing. This feature request would not be accepted by the community, as explained above.
from proposal-decorators.
Do you have any reasoning for yourself to prefer reusing an existing token, however? TC39 can worry about what's generally encouraged or discouraged in EcmaScript :-)
from proposal-decorators.
There's no resistance to adding new tokens nor any preference to prefer existing ones.
Okay, if that is true.
Do you have any reasoning for yourself to prefer reusing an existing token?
Few reasons:
- The code looks more familiar to JavaScript. If we continue introducing new symbols in every new ES version, we will end up using all unicode characters as keywords or operators.
- Code highlighters and editors will not be forced to deal with extra new tokens. Just a bit of modifying old tokens in special contexts (where these tokens were not allowe din previous version) will solve the problem.
- Similarly for JavaScript parsers and code beautifiers and obfuscators
TC39 can worry about what's generally encouraged or discouraged in EcmaScript.
I agree. Basically, I suggested, but TC39 will decide is it good or bad.
from proposal-decorators.
Regarding code highlighters and editors (and parsers and beautifiers and obfuscators), it's the same change to highlight a new token, or to change their parsing of an old token - any grammar change forces these things to adapt.
As for "looks more familiar", imo that's a reason to use a new symbol - it's not a good thing if it looks familiar but doesn't do something familiar.
from proposal-decorators.
Related Issues (20)
- Stage 3 allow decorators to generate PJOs HOT 1
- Timeline / proposal for extensions? HOT 8
- Using accessors makes code less clean and readable HOT 21
- Counterintuative ordering when using `accessor` in combination with `init` methods HOT 37
- Can't dynamically set private field in initializer HOT 17
- Context.private doesn't seem to support group accessor HOT 1
- Support changing the backing field used by auto-accessors HOT 2
- Towards stage 4 HOT 14
- Field and Accessor initializers should run after the field/accessor has been defined HOT 12
- Stage 3 cannot access the class for static method decorator HOT 3
- Idea: syntax for decorator composition. HOT 3
- How to exclude methods from class decorator HOT 2
- Add target class to the context HOT 6
- Order of execution HOT 3
- It isn't clear when `addInitializer` functions are called on class decorator HOT 2
- feature request (separate proposal?): `context.addPostInitializer()` HOT 18
- Readme text and types are outdated against actual spec HOT 2
- Field decorator initializer should support configurable field HOT 8
- Was there a purpose for non-lexical ordering of decorator applications? HOT 2
- Write upgrade guide for previous iterations to Stage 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-decorators.