Re: [fpc-pascal] Checking assignment compatibility

2014-01-06 Thread Mark Morgan Lloyd
Jonas Maebe wrote: 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 se

Re: [fpc-pascal] Checking assignment compatibility

2014-01-06 Thread Mark Morgan Lloyd
Michael Van Canneyt wrote: On Mon, 6 Jan 2014, Mark Morgan Lloyd wrote: 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) = Ty

Re: [fpc-pascal] Checking assignment compatibility

2014-01-06 Thread Jonas Maebe
On 06 Jan 2014, at 10:31, Michael Van Canneyt wrote: On Mon, 6 Jan 2014, Mark Morgan Lloyd wrote: 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; b

Re: [fpc-pascal] Checking assignment compatibility

2014-01-06 Thread Michael Van Canneyt
On Mon, 6 Jan 2014, Mark Morgan Lloyd wrote: 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 a

Re: [fpc-pascal] Checking assignment compatibility

2014-01-06 Thread Mark Morgan Lloyd
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. Bu

Re: [fpc-pascal] Checking assignment compatibility

2014-01-06 Thread Michael Van Canneyt
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 n

[fpc-pascal] Checking assignment compatibility

2014-01-05 Thread Mark Morgan Lloyd
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)); which- as I understand it- checks that the types are strictly the same. How do I relax this to only ensure that the parameter is as