tuple-syntax

Lance Bachmeier no at spam.net
Tue Mar 19 16:47:53 UTC 2024


On Tuesday, 19 March 2024 at 15:33:09 UTC, ryuukk_ wrote:

>> The comma is used as a separator. A trailing comma isn't used 
>> that way, so it looks weird to me. The spec says, "void has no 
>> value", so we already have a way to represent something that 
>> doesn't have a value: `(void)` and `(1, void)`. Although 
>> that's more verbose, I'm not convinced there's enough benefit 
>> to warrant the introduction of new syntax.
>
> void? everyone went with `_`
>
> even java.. https://openjdk.org/jeps/456  .. java.. who would 
> have thought

Are tuples with 0 or 1 elements going to be used enough to 
justify new syntax that duplicates what we already have in the 
language? Not just void, but also a.tupleof.

`_` won't work for D, because that would be a breaking change, 
and I don't see any way there would be sufficient benefit to 
justify it. The underscore is used in C codebases (I've 
encountered it at least twice, including the one I'm working with 
right now) and I use it in foreach loops.

Python uses trailing comma syntax. Assuming new syntax is 
desired, that would be a natural choice, even if it's ugly.


More information about the Digitalmars-d mailing list