-
|
At the top level, braces are optional. The contents become a struct if there's a field. If there's no field, it's not a struct. Not a struct: A struct that doesn't need braces: This is really nice, and I wonder why I need braces in a list of structs: This is a two-element list. The elements are structs with one field each. Would it be ambiguous to write it without braces? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
With your proposed syntax, how would one know where the boundary between the structs is? Or how many structs there are? This is not an issue with the top-level struct because it's always one struct. |
Beta Was this translation helpful? Give feedback.
-
|
True. I forgot that commas also separate struct members. I rarely use them in structs. |
Beta Was this translation helpful? Give feedback.
With your proposed syntax, how would one know where the boundary between the structs is? Or how many structs there are?
This is not an issue with the top-level struct because it's always one struct.