www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - To auto or not to auto?

Hi all.

I'm currently working on improving my cairo (a 2D drawing library, if
you haven't heard of it) bindings for D with an OO layer, and I'm trying
to decide if I should make all the resource classes auto.

The thing is, cairo uses a reference counting system to manage the
lifetime of objects.  I imagine this is partially because on various
systems, the number of, say, drawing contexts you can have at once is
limited.  Thus, you naturally want these objects freed as quickly as
possible.

So my first reaction was to make all the classes auto so that it's
impossible (or at least very, very difficult) to leave stray objects
lying around, waiting to be GCed.

But this means that none of the objects can be stored in, say, member
variables, or globals, etc.  Considering that the library is for drawing
2D graphics (both in and out of GUI environments), is there any major
drawback to using auto classes—enough to make them non-auto and risk
leaking resources?

My thanks to the many people on this NG who are *way* smarter than I am :)

	-- Daniel

-- 

v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D
a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP    http://hackerkey.com/
May 05 2006