ponce

Steven Schveighoffer schveiguy at yahoo.com
Wed Nov 10 06:14:24 PST 2010


On Tue, 09 Nov 2010 15:42:06 -0500, bearophile <bearophileHUGS at lycos.com>  
wrote:

> 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).

The problem with scoped classes are that they are reference types  
allocated on the stack.  This is highly prone to memory problems,  
especially when classes are usually expected to be in the heap (less care  
about storing into a global).

I'm assuming compile-time classes will be reference types allocated in the  
data segment.  This is more similar to string literals than scope  
classes.  I'm guessing that the resulting class must be immutable, no?   
Otherwise, how do you allow mutable functions on a class allocated in ROM?

FWIW, I like scope classes for optimization (I use them a few places in  
dcollections), but emplace should be sufficient to replace it.

-Steve


More information about the Digitalmars-d-learn mailing list