scope keyword in 'parameter' context
Robert Fraser
fraserofthenight at gmail.com
Mon Apr 21 17:20:35 PDT 2008
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?
More information about the Digitalmars-d-learn
mailing list