[fpc-pascal] What's a unit?
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Tue Feb 19 17:49:53 CET 2013
Sven Barth wrote:
>> OK, so is it possible to set up a constant extended record (i.e. the
>> work being done entirely at compilation time) that mimics an
>> instantiated object? Would
>>
>> if LibCapShim is TObject then
>> ..
>>
>> be safe where LibCapShim could be either an object (possibly nil) or a
>> constant extended record?
>
> You could try to overload the "is" operator for your to be defined
> static record [AFAIK it should work]. E.g.
>
> === code begin ===
>
> TLibCapShim = record
> cap_get_proc: tcap_get_proc;
> // ...
>
> class operator is (aLeft: TLibCapShim; aRight: TClass): Boolean; inline;
> end;
>
> class operator TLibCapShim.Is(aLeft: TLibCapShim; aRight: TClass): Boolean;
> begin
> Result := False;
> end;
>
> === code end ===
Thanks Sven, looks interesting and I'll play with it presently. Can an
extended record's fields/methods be set up at compilation time, or do
they need to be done by code?
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list