RE: [gtkmm] "manage" and Glib::RefPtr



Am Don, 2002-10-10 um 15.08 schrieb Butler, Gerald:
> > >   - new and delete [C++'s way]
> > This is the only thing that won't work anymore.
> > 
> 	Ouch! Personally, I wouldn't like this at all. Remove standard C++
> memory management from the mix. Very unpalatable IMHO. ;-)

I've no idea why new/delete is widely regarded as standard C++ memory
management.  The standard way of memory allocation in C++ is on stack.

Furthermore, you've to take into account that we aren't talking about
creating/destroying independent blocks of memory.  We're talking about
GTK+ widgets that interact which each other and have dependencies all
over the place.

Calling delete directly is rather low level.  It is not exception safe
and doesn't have any benefits at all when applied to gtkmm widgets --
the infrastructure to manage this automatically is already in place in
GTK+.

Advanced C++ coding techniques are all about scope-based resource
allocation and Glib::RefPtr<> would support that paradigm (since it does
scope-based reference counting).  And we wouldn't forbid you to use
delete in your code, we'd just forbid you to use it with gtkmm widgets
which is acceptable and even desireable IMHO.

--Daniel





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