Re: Recursive Algebraic

2018-06-30 Thread Mr.Bingo via Digitalmars-d-learn
The problem is that it seems that when one has a parameterized type, you must completely specify the parameters when using Algebraic, Algebraic!(T, Vector!int, Vector!(double, 3), Vector!(double, 3), ...)[] data; to be able to encapsulate an Algebraic on Vector(as a collection of all fixed

Recursive Algebraic

2018-06-30 Thread Mr.Bingo via Digitalmars-d-learn
I'm trying to create a vector of vectors(more general than vectors or matrices). The idea is that a Vector can contain another Vector or another type. Vector can be specified to be fixed in length or dynamic for efficiency. Vector!(T, N) creates a vector of leaf type T and length N. If N = si

Re: Implementing a tree with recursive Algebraic

2018-06-15 Thread Kamil Koczurek via Digitalmars-d-learn
On Friday, 15 June 2018 at 14:57:33 UTC, Adam D. Ruppe wrote: You can make the tree store a *pointer* to a tree though. That's the traditional way to do it and it works here too. Oh, alright. I changed Tree to be a class instead of a struct and it seems to work just fine now. Thanks a lot!

Re: Implementing a tree with recursive Algebraic

2018-06-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 15 June 2018 at 14:53:13 UTC, Kamil Koczurek wrote: Can I somehow fix this, or is my approach inherently flawed? A tree there would be storing a copy of a tree which is storing a copy of a tree... where would it end? You can make the tree store a *pointer* to a tree though. That's

Implementing a tree with recursive Algebraic

2018-06-15 Thread Kamil Koczurek via Digitalmars-d-learn
Hi, I'm trying to implement a simple tree and this 3-liner was my initial idea: struct Tree(T) { Algebraic!(Tree, T)[] content; } But it doesn't work and I get the following error message: /.../variant.d(...): Error: struct `app.Tree` no size because of forward reference /.../variant.d(...)