[fpc-pascal] A better way?
pascaldragon at googlemail.com
Fri Apr 15 10:51:21 CEST 2016
Am 15.04.2016 10:46 schrieb "Tony Whyman" <tony.whyman at mccallumwhyman.com>:
> If you want to get rid of (ugly) typecasts then maybe you should
investigate the "absolute" keyword. You get a lot of examples in the LCL.
For example, here's one I chose at random:
> function TGtk2WidgetSet.RawImage_CreateBitmaps(const ARawImage:
> ABitmap, AMask: HBitmap; ASkipMask: boolean): boolean;
> GdiObject: PGDIObject absolute ABitmap;
> GdiMaskObject: PGDIObject absolute AMask;
> Desc: TRawImageDescription absolute ARawImage.Description;
> You could describe it as typecast done in the var clause of a method. The
right hand identifier is not restricted to function parameters.
While it works using "absolute" for a public API is rather unsafe (I'd only
use that in private methods). In those cases the "as" operator should he
used (or at least "is" plus returning an error).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal