Recursive data-types

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 27 07:06:24 PDT 2014


On Sat, Sep 27, 2014 at 11:26:31AM +0000, ponce via Digitalmars-d-learn wrote:
> I'm dabbling with Scheme interpreter and ultimately I would need to
> declare the following types.
> 
> --------------
> 
> struct Function
> {
>     Environment env;
>     Atom params;
>     Atom body_;
> }
> 
> // An atom is either a string, a double, a symbol, a function or a
> // list of atoms
> alias Atom = Algebraic!(string, double, Symbol, Function, This[]);
> 
> --------------
> 
> These definitions can't work since Function and Atom need each other
> in this recursive definition.
[...]

What about using Atom*[] instead of Atom[]?


T

-- 
Microsoft is to operating systems & security ... what McDonalds is to gourmet cooking.


More information about the Digitalmars-d-learn mailing list