CokeScript icon indicating copy to clipboard operation
CokeScript copied to clipboard

Omitting parentheses

Open ghost opened this issue 10 years ago • 5 comments

It would be nice you could omit parentheses at function call (just like CoffeScript or Ruby). CokeScript compiler code is so easy to read! Thank you for your project.

ghost avatar Jul 12 '15 15:07 ghost

Thanks for your kind words. I am not sure what you mean by omitting parenthesis. You can definitely omit then on the declaration:

def test
    1 + 1

Maybe you mean omitting at call time? It is not impossible to do but it is definitely a more complex process.

batiste avatar Jul 13 '15 11:07 batiste

Sorry I read again and I have seen you said at call time. This definitely possible to implement but I have personally a strong distaste for omitting then at call time. This is against the explicitness of Python and I find it makes the source code more difficult to read.

I am discovering how CoffeScript works, e.g.

 a = -> 1 + 1
 a # not called here
 a 1 # called: a(1)
 a 1, 2 # called: a(1, 2) 
 a 1 2 # error

It kinda make sense and should be rather easy to implement as the syntax seems to be non contextual to previous function declaration.

batiste avatar Jul 13 '15 14:07 batiste

@batiste , I think that this is only because you didn't used to it. I like way it was implemented in CaffeineScript: https://github.com/caffeine-suite/caffeine-script/wiki/Function-Invocation

Also I'd like to sugges block comment / array / object / string literals from that project. It's really clean-looking.

vlad0337187 avatar May 03 '18 22:05 vlad0337187

@vlad1777d I have used them in Ruby and I have found it makes some piece of code extremely difficult to read.

Explain to me what that does:

a b c

Is it a(b, c) or is it a(b(c)) ? It terribly ambiguous to me and to many people that are used to c-like language a clear loss in readability.

batiste avatar May 04 '18 08:05 batiste

@batiste, in CaffeineScript it's passing arguments to some function: a(b, c).

If such happens, explicit specifying of parenthesis could help. Btw, in CaffeineScript there is also block function invocation, like:

a
    b
    c

Looks enough clean: screenshot from 2018-05-04 21-19-00 Line 129, for example. =)

vlad0337187 avatar May 04 '18 18:05 vlad0337187