ponce

bearophile bearophileHUGS at lycos.com
Tue Nov 9 12:42:06 PST 2010


Don:

> Yes. The rules will be:
> * no globals (same as pure).
> * no unsafe features (eg, no asm).
> * source code must be available.
> Everything else should work.

If a class is instantiated at compile-time the memory of its instance goes in the static mutable memory, but then the GC has to manage it differently, because you can't deallocate that memory. Is this a problem? It looks a little like the problems with scoped classes (that are now deprecated by Andrei).

(Time ago I have read an interesting paper about a C-like language that supports some kind of classes too. This language is designed for embedded CPUs, so classes may be allocated at compile time only, and never at runtime (where there isn't a dynamic heap), and the compiler takes even care of compacting and squeezing the class instances in the static memory (to reduce as possible the amount of memory they use). Allocating objects at compile time may be a performance optimization for D).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list