-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Postfix Block Expression #3
Comments
It should compile to the first case if we add it. You prefer this style because the parenthesis doesn't need to wrap, right? It wouldn't be too hard to add to the grammar, but I think it could look a little funky on a single line, or for methods that don't take prior arguments. You're proposing:
Versus the current compiler's:
Do you have any real examples where it helps make things clearer? |
Partly i like it because it eliminates the need for specifying the end of a block twice. Typing ".)" is really awkward in my opinion, when I want to be able to define my own control structures. Also, it drastically simplifies providing multi-line functions as parameters when you throw significant indentation into the mix. |
It would be cool if CoffeeScript's lexer were smart enough to insert a period into the token stream for you, when you had an unclosed block within an outer parentheses. This may be do-able by counting parentheses. So:
|
That would be nice, but significant indentation would also remove that problem. |
My problem then is that I'm still specifying the end of the block twice - both with a paren and a dedent, or a paren and a period.. I'd rather get rid of the parens, but I guess it's just a pet peeve of mine. |
Sorry, the block syntax is just too limited -- mentioned in the other issue. No multiple function arguments, and it has to be the last one. It wouldn't always be possible to call to with JS libraries with if they expected either. Closing as a "wontfix". |
This version is directly executable, and illustrates more directly the concept. One can comment out line jashkenas#3 and run again to see the difference.
So, I'd really like something along the lines of ruby, that let you pass an additional argument to a function as a block specified after the function call, i.e:
This would be semantically equivalent to either:
or:
myFunc(1,2)(x=>alert(x).)
The text was updated successfully, but these errors were encountered: