any news on const/invariant?

Walter Bright newshound1 at digitalmars.com
Mon Nov 26 21:24:13 PST 2007


Bill Baxter wrote:
> 0ffh wrote:
>> Derek Parnell wrote:
>>> I am under the impression that this is a fairly common way of doing 
>>> things.
>>>
>>>    byte[] bitmap;
>>>
>>>    bitmap = LoadBitMapFromFile("worldroadmap.bmp");
>>>    GammaAdjust(bitmap, 0.20);
>>
>> void GammaAdjust(ref byte[] bitmap,float gamma) ?
> 
> byte[] bitmap;
> bitmap = LoadBitMapFromFile("worldroadmap.bmp");
> byte[] same_bitmap = bitmap;
> GammaAdjust(bitmap, 0.20);
> assert(bitmap.ptr is same_bitmap.ptr, "Error GammaAdjust not supposed to 
> change the bitmap pointer");
> 
> 
> Sometimes it's convenient to have more than one reference to the same 
> buffer around.

I'm not sure why one would need protection against changing the bitmap 
pointer. GammaAdjust should just take a byte[], not a ref byte[].



More information about the Digitalmars-d mailing list