scope keyword in 'parameter' context

Spacen Jasset spacenjasset at yahoo.co.uk
Tue Apr 22 08:46:01 PDT 2008


Robert Fraser wrote:
> Spacen Jasset wrote:
>> I have this construct, but would like the new Image to be collected 
>> after it is used in the Texture constructor.
>>
>> texture = new Texture(new Image("data/models/cp2/a1.jpg"));
>>
>> I cannot say this, but would like to:
>>
>> texture = new Texture(scope new Image("data/models/cp2/a1.jpg"));
>>
>> Is there any workaround, other than:
>>
>> scope Image image = new Image("data/models/cp2/a1.jpg");
>> texture = new Texture(image);
>>
>> Presumably I could write some sort of mixin, which I haven't yet used 
>> at all in D.
>>
>>
>> This may seem trivial, but it can be a pain where I want to do the 
>> same thing over, and know that I don't want to keep the Image object, 
>> and infact in some cases I *must* make sure it is collected before the 
>> end of main, as the library calls it uses become unavailable, as the 
>> library is unloaded at the end of main scope.
> 
> How about deleting it at the end of the image constructor?
Yes true, but I don't always want it deleted.


More information about the Digitalmars-d-learn mailing list