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

Change Array Splat Symbol from Asterisk to Ellipsis #45

Closed
jashkenas opened this issue Jan 6, 2010 · 8 comments
Closed

Change Array Splat Symbol from Asterisk to Ellipsis #45

jashkenas opened this issue Jan 6, 2010 · 8 comments

Comments

@jashkenas
Copy link
Owner

Douglas Crockford suggested changing the array splay symbol from * to ..., which would read like this:

race: winner, runners... =>
  print(winner, runners)

I think it's lovely. Any objections?

@jashkenas
Copy link
Owner Author

It needn't:

gold, silver, bronze: runners...

Multiple splats on the same line will look a little funky, but it's a small price to pay. This (ellipsis splats for function defs and calls, not exploded assignment) is now on master. Closing the ticket.

@jashkenas
Copy link
Owner Author

Just to read well. The * operator was alright, because of the kleene star connotation, but can look an awful lot like multiplication when skimming over code. I like the ... because it implies uncertainty about the length of the arguments.

family(mother, father, children...)

budget(food, shelter, misc_expenses...)

Also, I didn't realize this, but apparently it's the way to do splats in C and Java:
http://en.wikipedia.org/wiki/Ellipsis#In_programming

@jashkenas
Copy link
Owner Author

It's supported on the current master. I agree that it's not ideal, but still the better of the two options. Your first example compiles into this:

foo.apply(this, abc.concat([42]));

@omni5cience
Copy link

Sorry for commenting on a closed issue, but I followed a link here and I can't help but feel like this reads like one side of a conversation. Am I missing something obvious?

@jashkenas
Copy link
Owner Author

Huh. Maybe the other person deleted their github account? Or maybe it's a bug.

This issue was 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

2 participants