[SDL] [SDL/C++] Garbage Collection

Pierre Phaneuf pphaneuf at gmail.com
Tue Jan 27 21:39:03 PST 2009


On Tue, Jan 27, 2009 at 11:23 PM, Donny Viszneki
<donny.viszneki at gmail.com> wrote:

>> It *is* possible to put that reference in a new
>> object, but it would be bad form (just like you can make C++
>> references be NULL, but it's reasonable to say "hey, don't do that,
>> it's evil!").
>
> I once wrote a class whose members lied in sub-fields of "this" cast
> as an address-sized union. This way I could create 2^32 instances of
> the class without allocating any memory. This only worked because the
> instances are all immutable and only existed as a programming
> abstraction using CPP macros. (Why not just use macros and leave C++
> classes out of it? I wanted the member methods to be compiled once,
> and I wanted my program to actually enter those methods, I did not
> want them inlined.. not all of them anyhow!)

Perfect example.

Don't do that, it's evil! :-)

-- 
http://pphaneuf.livejournal.com/



More information about the SDL mailing list