-
Notifications
You must be signed in to change notification settings - Fork 6
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
Parentheses #3
Comments
Personally I find [2] more readable than [3], because the brackets isolate the function name better. It may be a matter of habit, but I do find for instance that [2] makes skimming easier: if I want to know what operations a piece of code is doing, I can spot parentheses and check what's to their left, whereas blanks are more ambiguous. Furthermore, in Ruby/CoffeeScript, expressions like Either way, what you propose is currently impossible because line breaks are exactly like commas, and have the same priority as commas. So if you wrote, for instance:
That would be equivalent to This being said, I am considering adding back semi-colons to serve as that low-priority separator instead (their usage would not be required, of course). Then I would raise the priority of the comma above that of the
You might prefer something terser, but |
To omit parentheses is not always a good idea, especially if you have a function inside a function. However sometimes I think it makes code more readable. To omit parentheses is always optional. I think adding back semi-colons is a good idea. The following code is fine:
I think it could be better if we could use a symbol as "with" alias. I don't know which symbols are avaible yet (few I guess). Some suggestions:
(Whitespaces could be significative) If we don't pass any params to a function, instead of:
we could code something like this:
Maybe these sytanxes are a little weired. But I'd like to have a "with" keyword shortcut. |
I committed the changes with semicolons and commas (so
Really, the best candidate would be Thanks for the feedback :) |
It would be very very nice! :) |
Just adding 2c here. I've used LiveScript (which like CoffeeScript allows omission of parens) for quite a while now and have come to the conclusion that, readability aside, [2] leads to less errors than [3]. Consider:
Is that Also I understand that |
In my criteria when designing Earl Grey, I rank consistency over familiarity, meaning that most of the time I will implement unfamiliar syntax if I feel it leads to a more consistent design. In my estimation, few popular languages put any thought into syntactic consistency, which is why EG will sometimes be "weird" (because I try to "correct" what I think they do wrong). Now, to me, variable definition and object field definition are extremely similar operations: we bind a name to a value, in one case in the lexical scope, in the other case inside an object. Moreover, there is no common situation where it would be ambiguous whether we mean one or the other. So I can't see any good reason why there should be two different operators to do these incredibly similar, non-interfering things. So I pick one operator for definitions ( I'm not alone in this choice, of course. Lua's table literals use the same syntax as EG. |
I think that makes sense and I tend to agree that one need not be held back by convention where there is a good reason. Thank you for taking the time to write your thoughts. Regarding
Are you pretty well set on |
It's an operator priority issue.
Control structures do take arguments, the idea is that Anyway, let's see...
...I don't know, I think |
Thanks. Personally I agree, as too many syntaxes that mean the same thing make a language quite complicated. By the way I took |
I think [2] is the right solution. I very much dislike the omission of parens in CoffeeScript, it makes code unreadable in my opinion. |
@tacomanator Yeah, there is some elegance to LiveScript's |
I agree with @shadowhand -- I never like the omitted parens in CoffeeScript. Far too often I find I'm adding/removing chaining while editing code, which means adding/removing parens, which becomes tedious. Just leave them on. If you're going to use a symbol (other than just a space char), parens are by far the cleanest option listed here. |
Parentheses are often syntax noise. For example, if we have a silly function like this [1]:
we can call the function like this [2]:
we can't omit parentheses (like in ruby or coffeescript) [3]
I understand the reason. In Earl Grey we could code something like tihs: [4]
However [3] is the most readable piece of code. So I suggest some syntax sugar like this:
It's just an idea. What do you think about it?
Thank you for Earl Grey.
The text was updated successfully, but these errors were encountered: