Apples and Oranges

Georg Wrede georg.wrede at nospam.org
Mon Apr 10 16:43:56 PDT 2006


kris wrote:
> Bruno Medeiros wrote:
> 
>> kris wrote:
>> All of those pros you mention are valid. But you'd have one serious con:
>> * Any class which required cleanup would have to be manually memory 
>> managed.
> 
> Can anyone come up with some examples whereby a class needs to cleanup, 
> and also /needs/ to be collected lazily? In other words, where raii or 
> delete could not be applied appropriately?

Got another idea.

It seems to me that this discussion is pretty abstract. Normally, half 
the participants would be talking about Apples and the other about 
Oranges, without neither noticing. But in this D newsgroup, I believe 
the state of knowledge is high enough for such not to happen.

However, half of the _audience_ may not be that clear on that both 
apples and oranges belong to the Class Magnoliopsida, and one of them to 
the Order Rosales and the other to Sapindales. But which? (And I 
certainly admit I belong to this Audience here.)

To serve and accomodate all, and to even possibly start to get 
potentially worthwhile commentary from a larger group of eyes, I suggest 
we try to construct the simplest Structure of Instances needed to 
display _all_ of the discussed woes.

As a first draft (and not even remotely pretending it is adequate), I 
cast the following:

VIEW THIS IN MONOSPACE FONT
===========================

code                   heap


iRa -----------------> alpha ---> beta
                         ^          /
                          \        /
                           \      /
                            \    V
                             gamma
                             ^  ^
                            /    \
                           /      \
                          /        \
                         V         V
iRb ----------------> delta <--> epsilon

(Oh, iR stands for Instance Reference, just to not get involved with the 
types or classes:

SomeClass iRx = new SomeClass();  // Create a reference to an instance.
)

So, the upper half makes a singly linked list and the lower half makes a 
doubly linked list, and then there arem two references (or D variables) 
pointing to the Alpha and Delta instances.

Can this structure demosnstrate _all_ of the problems we're currently 
discussing, or should it be more complicated?



More information about the Digitalmars-d mailing list