Self-referential tuples?
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 10 09:26:16 PDT 2015
On 06/10/2015 05:52 PM, Brian Rogoff wrote:
> On Tuesday, 9 June 2015 at 23:48:05 UTC, Timon Gehr wrote:
>> 'This' is a cute hack, but it doesn't replace a proper template
>> fixpoint operator.
>
> Could you explain this a bit more, maybe using some pseudo-D for your
> proposed template fixpoint operator? Thanks.
> ...
import std.typecons, std.variant;
alias List(T)=Algebraic!(Tuple!(),Tuple!(T,List!T*));
void main(){
List!int l;
}
The following error message is the reason why the 'This' hack is necessary:
tt.d(3): Error: template instance Algebraic!(Tuple!(), Tuple!(int,
List!int*)) recursive template expansion
tt.d(6): Error: template instance tt.List!int error instantiating
The simple solution is to just not have this error. The code can easily
be given an unambiguous meaning.
More information about the Digitalmars-d
mailing list