Skip to content
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

Remove parentheses on function calls with no parameters #2100

Closed
ollym opened this issue Feb 3, 2012 · 7 comments
Closed

Remove parentheses on function calls with no parameters #2100

ollym opened this issue Feb 3, 2012 · 7 comments

Comments

@ollym
Copy link

ollym commented Feb 3, 2012

It's ugly and such a pain having to do foo.bar() just because the function has no parameters. Can we use the ! operator to call the function? 1 symbol is always easier than 2.

foo.bar! => foo.bar()

And with existence operator:

foo.bar!?.baz is equivalent to foo.bar()?.baz

So....

Array::empty = -> @length > 0

if array.empty! then throw 'Array is Empty!'

I understand this may confuse some ruby developers - but in my option we're already confusing them with the use of ? for the existence operator.

Thoughts?

@ollym
Copy link
Author

ollym commented Feb 3, 2012

Just seen this relates to #514 and #1412 guess people don't like the bang idea :(

@ollym
Copy link
Author

ollym commented Feb 3, 2012

maybe

foo.bar..baz => foo.bar().baz

and

foo.bar.?.baz => foo.bar()?.baz

But even then we're still using 2 characters. .. is still cleaner and easier than ()

@showell
Copy link

showell commented Feb 3, 2012

I think parens win strongly on readability, just because it's such a common way to call a function. You can also say "do foo".

@ollym
Copy link
Author

ollym commented Feb 3, 2012

I see it more as a way to adding getters to coffee script using syntax rather than requiring it within the VM.

@rlidwka
Copy link

rlidwka commented Feb 4, 2012

if you dont want parens for some reason you always can write do something which translates to function call

I see no point in increasing complexity of a language just to win one character

@geraldalewis
Copy link
Contributor

foo.bar! => foo.bar()
I see it more as a way to adding getters to coffee script

I think that'd create some dissonance with Ruby's precedent of identifiers ending with ! mutating the object's state.

I'm pretty sensitive to parens and other sigils, too, but when it matters I use do as others have suggested.

@michaelficarra
Copy link
Collaborator

I think this one's ready to be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants