Tuple DIP

Q. Schroll qs.il.paperinik at gmail.com
Sun Jan 14 15:00:25 UTC 2018


On Sunday, 14 January 2018 at 00:01:15 UTC, rikki cattermole 
wrote:
> On 13/01/2018 11:45 PM, Timothee Cour wrote:
>> some people have suggested using `{a, b}` instead of `(a,b)` ; 
>> this
>> would not work because of ambiguity, eg:
>> `auto fun(){ return {}; }`
>> already has a meaning, so the empty tuple would not work.
>> so `()` is indeed better.
>
> Easy fix, tuples must have a length greater than 0.
> A tuple with length 0 is by definition void.

Zero tuples exist and don't have type void as their type has an 
object: the empty tuple. It's similar to the empty word, the 
empty array, etc.
They naturally arise in corner cases of templates. You have to 
support them like static arrays of length 0.
Effectively forbidding them would be an unreasonable limitation.


More information about the Digitalmars-d mailing list