Aggregates & associations

Bruce Adams tortoise_74 at yeah.who.co.uk
Thu Dec 20 03:27:40 PST 2007


On Thu, 20 Dec 2007 00:49:05 -0000, Sean Kelly <sean at f4.ca> wrote:

> Bruce Adams wrote:
>> On Wed, 19 Dec 2007 20:41:58 -0000, Sean Kelly <sean at f4.ca> wrote:
>>>
>>> Interestingly, if objects are constructed inside the memory reserved  
>>> for other objects, then if one is collected by the GC it must be true  
>>> that all other objects in the same block are free as well.  Also,  
>>> since they share memory, all the objects can safely refer to one  
>>> another in their dtors so long as they are careful to avoid using  
>>> member data that may already have been released.  As you say, this  
>>> promises to offer some interesting possibilities for composite objects.
>>  Except that at present there's no way to declare that an object is  
>> contained in
>> another object except as a struct and a struct is not an object. I  
>> don't think
>> scope would do this and if it did it would be ahem beyond its scope to  
>> do so.
>
> Why?  It works this way for class variables declared elsewhere.  As a  
> QOI feature, but still...
>
>
> Sean

Sorry I should have qualified that. Scope as I understand it, declares  
whether
a variable should be deleted or it. i.e. whether it is owned by the  
current scope,
which in the proposed extension would mean class scope. It does not say  
anything
about the memory layout. Whether the object is a value or reference is  
still up
for grabs. It doesn't usually matter in functions but in a class it does,  
at least
as an optimisation.
I think something like the "val" syntax would make this kind of  
optimisation possible
as well as solving the pass by value, pass by reference optimisation  
problem.

Bruce.



More information about the Digitalmars-d mailing list