Self-referential tuples?

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 9 17:16:43 PDT 2015


On 06/10/2015 01:52 AM, Andrei Alexandrescu wrote:
> On 6/9/15 4:43 PM, Idan Arye wrote:
>>
>> The `This*` here is not mapped to `Algebraic!(Tuple!(),Tuple!(T,This*))`
>> - it's mapped to the closest containing tuple, `Tuple!(T,This*)`. This
>> means that the tail is not a list - it's a head and a tail. The list is
>> either empty or infinite.
>>
>> At any rate, I think this feature is useful enough even if it doesn't
>> support such use cases. You can always declare a list as a regular
>> struct...
>
> Way ahead of you :o). Algebraic would use std.variant.This, whereas
> Tuple would use std.typecons.This. So you get to choose. -- Andrei

I generally assume that the same identifier in the same scope of the 
same code snippet refers to the same symbol, but sure, this avoids this 
specific problem, but not others.


More information about the Digitalmars-d mailing list