Change Array Splat Symbol from Asterisk to Ellipsis #45

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

2 participants

@jashkenas
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
Owner

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
Owner

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
Owner

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

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
Owner

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