DEV Community

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

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

That git requirement/problem is in my mind. I'd like to ensure that the source files are source control friendly.

I never thought about using ; to separate lists, though there's no real reason why I would distinguish between ; and ,. Just a classic syntax I guess, though semi-colons seem "heavier" than commas.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

In the rare occasion that I have inline list elements, I instinctively use commas then have to go back and replace with semi-colons. The compiler thinks I have one list item that is a tuple, since commas indicate tuples in F# (even without parens).

I do like the range of choices that are given by using either a separator char or newline. However in practice, I nearly always use the first style (newlines only). It is the most copy-paste and git friendly, and secondarily I like the visual flow.

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

I think the inline versus multiline choice depends on what type of code you are writing. Anything that involves a logical list of items I prefer newlines.

var items = [
  item_one,
  item_two(args),
  1 + 2,
]

But, sometimes I have little tuples, like points, that would be burdensome, and unclear to do multiline:

var a : point = [1,2]
var b = pt_a + [3,4]