tuple-syntax

Dom DiSc dominikus at scherkl.de
Tue Mar 19 10:04:06 UTC 2024


On Monday, 18 March 2024 at 23:52:22 UTC, Basile B. wrote:
> On Sunday, 17 March 2024 at 20:20:52 UTC, Dom DiSc wrote:
>> So, how about _always_ requiring a trailing comma?
>> This would make for a consistent syntax: (,) empty tuple, (x,) 
>> one-element tuple, (x,y,) two element tuple ...
>
> That works but I dont like that. In my opinion that would be a 
> case where the syntax would serve as a hint for the semantic 
> analysis. That does not break the principle of "context-free 
> grammar" however; just a bit odd to me.
>
> What about a property. Just `.tupleof`
[...]
::lots of other proposals by others::
[...]

Most of these were discussed in the talk, and all have cases 
where they become ambiguous or require new keywords / long syntax.
What I like about the trailing comma is that it's short, no new 
keyword, and always unambiguous.
Of course you could replace the comma by any other unused symbol 
('EOT' or '-' are bad ideas as the one is a new keyword and the 
other produces some ambiguous cases, but we could use ' or : or $ 
or whatever), but why?
Comma is an obvious choice and much less ugly than most of what 
I've seen else.


More information about the Digitalmars-d mailing list