GithubHelp home page GithubHelp logo

Comments (9)

littledan avatar littledan commented on August 16, 2024 3

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.

ljharb avatar ljharb commented on August 16, 2024 2

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.

ljharb avatar ljharb commented on August 16, 2024 1

Iā€™m confused; why would it be better to use a token with an existing meaning, rather than a new one?

from proposal-decorators.

 avatar commented on August 16, 2024 1

@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.

 avatar commented on August 16, 2024 1

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.

 avatar commented on August 16, 2024 1

Closing. This feature request would not be accepted by the community, as explained above.

from proposal-decorators.

ljharb avatar ljharb commented on August 16, 2024

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.

 avatar commented on August 16, 2024

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:

  1. 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.
  2. 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.
  3. 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.

ljharb avatar ljharb commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.