-
Notifications
You must be signed in to change notification settings - Fork 2k
Docs: Revise docs to use ES6 position of splats #4845
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
This was discussed in coffeescript6/discuss#85. We decided not to switch the docs because the style of CoffeeScript is to emulate English language syntax: that’s why it’s Just as we technically allow both |
Hmm, I can see your explanation but I'm not convinced by your reasoning there - There isn't an equivelent to splat, rest and spread in English. I think aligning with ES6 in the docs makes more sense than keeping a different implementation mainly for legacy reasons. @jashkenas here seems to suggest the same:
For those transitioning from JS to CoffeeScript changing the order of existing language features like this will be meaninglessly difficult. |
People who prefer the JavaScript syntax are welcome to use it. Most people who use CoffeeScript nowadays are using it for the more readable syntax. That’s kind of the point. The quote you chose is rather cherry-picked. Jeremy was referring to not allowing both syntaxes, not how we should present this feature in the docs. Obviously, by the end of the discussion we came to a different conclusion. One place where I find myself using the ES-style dots is spreads of function calls: export default
computed: {
...mapState 'user', ['user']
...mapGetters 'user', ['profile']
} This is a case where I have to choose between implicit parentheses and trailing dots. The same could be expressed via If you want to add an example like this to the docs, hopefully something a bit shorter and more interesting, that would be welcome. It would show not only that the leading-dot syntax is an option, but when there are benefits to using it. |
Which side of the variable Another way to think about this is that you could drastically simplify the Splats documentation by switching it up. Splats, or Rest Parameters/Spread Syntax --
Is it? I read it as Jeremy expressing that he'd adopt es6 syntax if he could, unfortunately you can't and keep things backwards compatible so you supported both. -- FWIW I think you're doing a great job juggling many concerns of the upgrade, allowing for both syntaxes here was a good move. This one just seems like an unneccessary divergence from JavaScript syntax for no gain. I'm thinking about JS dev's new to CoffeeScript - differences like this won't be positives, they'll be negatives. |
We could simplify the docs about function calls by neglecting to mention that parentheses are optional. We don’t, because we feel that even though you can write CoffeeScript that’s closer in syntax to JavaScript, that doesn’t mean we want the docs to encourage such a style. The same goes for the dots. I personally feel that That said, the docs would be improved by including an example of leading dots that makes sense, that doesn’t detract from the English-first preference of the docs’ overall style. If you’d like to submit such an example, please feel free to do so. |
I won't beat a dead horse any longer - you're the author. In 4 years writing CS I did always err on the side of JavaScript syntax when they were equal length:
|
Now that CoffeeScript supports splats, rest and spread on either side of the variable name I think it makes sense to adopt ES6's position in the docs:
after...
and...before
It will be easier to adopt for those already familiar with the syntax in JS.