DEV Community

Discussion on: Help design a language: What about tuples without commas?

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Definitely with commas. Imagine if I had this...

tuple = [1, 2, 3, 4, 5, 6, 7, 8, 9]

...and something changed to where I felt each element needed to be on a separate line. I'd have to actually go back and REMOVE all my commas, which feels like unnecessary work.

tuple = [1
         2
         3
         4
         5
         6
         7
         8
         9]

(and so on).

Or what about a mix? Do I need commas at the END of the line, which I'd feel compelled to add out of habit with all other languages?

tuple = [1, 2, 3
         4, 5, 6
         7, 8, 9]

Now, if the commas were merely optional in this case, I might see that as being workable. From there, we just get into Perl (TMTOWTDI) v. Python (TOOWTDI) philosophy.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

The commas would be optional on line end. All of the syntaxes you provided here would be acceptable.

Though I'd argue that mixing within a single tuple is perhaps not good practice -- I wouldn't go out of my way to forbid it though.

Collapse
 
17cupsofcoffee profile image
Joe Clay

Your latter example (mandatory between items on the same line but optional at the end of a line) is pretty much exactly how CoffeeScript objects and arrays work, so there's definitely precedent for that!

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Then again, CoffeeScript and its relatives aren't exactly widely considered a pinnacle of good language design. Useful, but not exactly elegant.

Thread Thread
 
17cupsofcoffee profile image
Joe Clay

Yeah, it's precedent, but not necessarily good precedent :p