[fpc-pascal] Checking assignment compatibility
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Mon Jan 6 10:20:40 CET 2014
Michael Van Canneyt wrote:
> On Sun, 5 Jan 2014, Mark Morgan Lloyd wrote:
>
>> Simulating a C-style conditional, I can do this
>>
>> function tf(const q: qword; const qt, qf: TObject): TObject; inline;
>>
>> begin
>> Assert(TypeOf(qt) = TypeOf(result));
>
> This is always true. Everything descends from TOBject.
>
> But assuming the result is not TObject, it would be
>
> Assert((qt=Nil) or (qt.Inheritsfrom(TheResultClass))
So again skipping the nil check for simplicity, this compiles but are
the semantics right?
Assert(qt.ClassType.InheritsFrom(result.ClassType));
> Although that is still radically different from what the C style macro
> does.
Yes, understood and being watched out for.
--
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