class allocators should be more encapsulated

Luís Marques luismarques at gmail.com
Fri Dec 29 05:33:47 PST 2006


Frits van Bommel wrote:
> I don't think that's what custom allocators were designed to do. They 
> should only allocate some memory (and register it with the gc if 
> necessary).

Well, allocators do take parameters. The only reason for that has to be 
being able to customize how the memory is allocated, right? From what I 
can see in my example my example still applies (I have seen several 
people use new for singleton patterns). Perhaps you disagree. Would you 
care to elaborate?

> Well, in D the factory method can be static opCall(), so allocation can 
> look like this:
>     ClassType("my string")
> which looks a lot cleaner than the normal ClassType.create("my string").

Well point out, thanks!

But still, isn't new ClassType("my string") better?



More information about the Digitalmars-d mailing list