On Tuesday, 9 June 2015 at 15:28:16 UTC, Andrei Alexandrescu
wrote:
Following the use of This in Algebraic
(https://github.com/D-Programming-Language/phobos/pull/3394),
we can apply the same idea to Tuple, thus allowing one to
create self-referential types with ease.
Consider:
// A singly-linked list is payload + pointer to list
alias List(T) = Tuple!(T, This*);
// A binary tree is payload + two children
alias Tree(T) = Tuple!(T, This*, This*);
// or
alias Tree(T) = Tuple!(T, "payload", This*, "left", This*,
"right");
// A binary tree with payload only in leaves
alias Tree2(T) = Algebraic!(T, Tuple!(This*, This*));
Is there interest in this? Other application ideas to motivate
the addition?
Andrei
Useful, not ground breaking. I would not add right now.