Re: RFC: glocal - automatically freeing memory when it goes out of scope



On 11/21/2011 04:51 PM, Ross Burton wrote:
On 21 November 2011 15:43, Dominic Lachowicz<domlachowicz gmail com>  wrote:
If you want this sort of behavior, use a language like C++ that
supports stack-allocated objects natively. GtkMM and GlibMM already do
this wonderfully. Using a GNU-C ism which probably won't work with
most other C compilers (MSVC, LLVM, ICC, ...) feels wrong to me.
We need a micro-C++ binding that looks exactly like traditional
GObject C but also hooks up the nice features like stack allocated
objects.  I don't like C++ but I'd consider a C++ compiler to compile
my C code if it could simplify memory management dramatically for
almost free. :)
Stack allocated GObjects would be sweet, but is unfortunately quite far from becoming a realistic option.

Compiling C code with a C++ compiler also brings other interesting things along; like name mangling and the fact that a struct is no longer a plain old C struct, but really a C++ class.

And generally mixing two type systems and two memory management systems brings too many "interesting" quirks along that I don't really want to go there. We've done this a *lot* in Unity and related projects and I never liked it.

Cheers,
Mikkel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]