Recursive data-types

2014-09-27 Thread ponce via Digitalmars-d-learn
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 =

Re: Recursive data-types

2014-09-27 Thread Rikki Cattermole via Digitalmars-d-learn
On 27/09/2014 11:26 p.m., ponce 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

Re: Recursive data-types

2014-09-27 Thread ponce via Digitalmars-d-learn
On Saturday, 27 September 2014 at 11:40:19 UTC, Rikki Cattermole wrote: How to get out of this trap? Do I have to drop Algebraic and go back to manual tagged unions? Converting Function to a class. No where near ideal. But it'll work. It does work! Thanks. Actually it's quite appropriate

Re: Recursive data-types

2014-09-27 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Sep 27, 2014 at 11:26:31AM +, 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

Re: Recursive data-types

2014-09-27 Thread Meta via Digitalmars-d-learn
On Saturday, 27 September 2014 at 11:26:33 UTC, ponce 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

Re: Recursive data-types

2014-09-27 Thread ponce via Digitalmars-d-learn
On Saturday, 27 September 2014 at 14:08:18 UTC, H. S. Teoh via Digitalmars- What about using Atom*[] instead of Atom[]? Atom[] seems simpler to me.

Re: Recursive data-types

2014-09-27 Thread ponce via Digitalmars-d-learn
On Saturday, 27 September 2014 at 15:45:20 UTC, Meta wrote: Also, you might want to use This* instead of This[], unless you want an Atom to be able to contain a whole array of other atoms. That's indeed what I want.

Re: Recursive data-types

2014-09-27 Thread thedeemon via Digitalmars-d-learn
On Saturday, 27 September 2014 at 11:40:19 UTC, Rikki Cattermole wrote: These definitions can't work since Function and Atom need each other in this recursive definition. How to get out of this trap? Do I have to drop Algebraic and go back to manual tagged unions? Converting Function to a