-
Notifications
You must be signed in to change notification settings - Fork 46
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
Maintain Syntax Compatibility with ES6 where possible and sensible #49
Comments
I agree that Spider should follow ES, unless there's a good reason to change the syntax. Another example:
|
@Skalman that is actually one place where I like the spider syntax! Though it does fall into the 'stay consistent with syntax where possible' principle. I think in this case ES6 had to come up with a strange syntax to not break existing strings. Spider can possibly support both formats. As the template strings can be used for powerful functions as well. Well, in any case, I'll be fine either way on this issue. |
Exactly. Why maintaining compatibility with ES6 is a goal? |
Maybe for making it easier to transition into/out-of spider. I think the changing syntax for the sake of changing syntax is not that compelling. Changing syntax for improvements in readability, go for it.
|
I think it makes sense to have the same syntax as ES6 for identical features. Again, I really like the swift string interpolation syntax, but I still get why keeping the However, Spider does have unique features and some unique syntax sugars, and there is no need to make everything identical to ES6 |
Even though they're similar, splats and rest parameters aren't the same thing. Spider's splats are much more powerful. For example, in ES6, you can't do:
This is a larger discussion. Should we add classes to Spider? #28
There are 2 reasons I separated
Readability. For example:
This was a purely opinionated decision. I just think that |
Here is my opinion on these things. Splats:I understand that the splats in Spider are more powerful. But the intention is the same as ES6 splats. Also, from a readability point of view Module Syntax:If ES6 module syntax has been added, this part is pointless for discussion. Class Syntax:Let's keep this discussion in the other issue. for-of vs for-inI think it makes sense to use only List ComprehensionI think the readability in this matter is a meaningless argument. It's like active and passive sentences in English. ES6 and Spider (taken from Python as far as I know) are both readable to me, but again, I think using the ES6 syntax will keep things more consistent for JS developers. Template Strings / String InterpolationIn this case I'm biased, and I like the Spider syntax Summary:I don't want this to be a long discussion, and I think, @alongubkin as the author of Spider you will have to make a call on the best syntax. My thinking behind this issue is this: Keeping that in mind, I think it makes sense to just port of javascript as-is, where changing the syntax doesn't have a benefit. (you have done this for many other parts of Spider). /end of opinion outburst. |
Splats - I agree, let's change that to Loops - Splitting ES6 List Comprehensions - I don't think readability is a meaningless argument here. Sure, it's a minor one, but it still exists. The reason why I think we should keep the Python syntax is: Spider doesn't require parenthesis around the test expression in an
would become the following in Spider:
so the only thing that separates between the condition's test expression and the result expression is whitespace, and that's a source of confusion. Moving the result expression before the
|
Cool. I see your point. I agree. On another note, would like some more documentation around for-in for-of. |
There are some features already implemented in Spider that have a similar but different syntax compared to ES6. These should be made consistent.
Examples I can think of:
...rest
, spider usesrest...
use
/ require vs the ES6 Module syntax[for x in list x * 2]
[x * 2 for x in list]
The text was updated successfully, but these errors were encountered: