Crystal: Remove the comma as an enum member delimiter

Created on 30 Mar 2019  路  8Comments  路  Source: crystal-lang/crystal

Following this discussion, delimiting enum members can be done with either a comma, a newline or a semicolon (and also a space at this time, which is a bug). Allowing an additional delimiter character like the comma isn't needed, as it acts similarly as the semicolon:

enum E
  A; B; C
  D, E, F
end

Most helpful comment

I'd remove the comma syntax. It's probably a breaking change but it's a weird syntax. There's nothing like that anywhere else in the language. Newline and semicolon are probably fine and enough.

All 8 comments

I'd keep it as a valid syntax, yet remove it by formatter as a preferred style.

We don't use semicolons anywhere else I think, why keep them over the comma?

Ah, nvm, because it's the same as newline. I'd reformat it to a newline here though I think.

I'd remove the comma syntax. It's probably a breaking change but it's a weird syntax. There's nothing like that anywhere else in the language. Newline and semicolon are probably fine and enough.

The closer syntax I see in the language is arguments:

puts(
  STDIN, STDOUT, STDERR
)

But enum members aren't arguments at all.

comma is more human readable .

comma is more human readable .

The enums with the members delimited by a newline or semicolon are human readable too IMO. And it's also about consistency. As @j8r said, enum members aren't arguments. You define something.

I don't think there is anything to brainstorm here: enum members must be separated by a linefeed, period.

A semicolon is only accepted because it acts as a linefeed, similar to how it's syntactically valid to inline constants, but we never do it, because it's ugly, and hinders readability:

FOO = 1
BAR = 2; BAZ = 3
Was this page helpful?
0 / 5 - 0 ratings