www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - out of memory error with template mixins

reply "Saaa" <empty needmail.com> writes:
I was trying out composite oriented programming, meaning moving class 
functionality into templates which you then mixin.
First part mixined just fine, second also ok, third . .
- Error : Out of memory (2GB VM)
Even with an empty template :(
Dec 02 2009
parent reply "Saaa" <empty needmail.com> writes:
Removing a struct definition from the second mixin seems to fix the problem.
Is this a (known) bug?

The struct was only used within that template.

public struct S
{
enum LOCAL { ONE, TWO };
LOCAL local;
bool b = false;
StructOut s;
ENUM_OUT eo;
}
 
Dec 03 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
Saaa:
 Is this a (known) bug?
It's generally better if you show a tiny compilable example that has the problem. Bye, bearophile
Dec 03 2009
parent reply "Saaa" <empty needmail.com> writes:
bearophile wrote:
 Saaa:
 Is this a (known) bug?
It's generally better if you show a tiny compilable example that has the problem. Bye, bearophile
I'm trying :) I just hoped somebody would recognize it from my babbling
Dec 03 2009
parent reply "Saaa" <empty needmail.com> writes:
Tomorrow I'll continue my quest for the mall piece of code which will choke 
the compiler. 
Dec 03 2009
parent reply "Saaa" <empty needmail.com> writes:
Can't recreate the error in a small test project (5 modules).
I think the problem lies somewhere in between cyclic module imports, mixin 
struct definitions and maybe the actual size of the class(1k) and its 
complexity of interfaces(8).

One more thing:
The out of memory is before it can tell there is an variable missing, 
although the error is also there when the variable is not missing. 
Dec 03 2009
parent "Saaa" <empty needmail.com> writes:
module project.foo.templates.bar;

template Bar()
{
  //struct is not used anywhere
  public struct Eye{} //comment this line out and the error is gone.
}
Dec 03 2009