[fpc-pascal] parent class as a parameter type
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Nov 14 22:03:28 CET 2011
On 13 Nov 2011, at 17:56, Graeme Geldenhuys wrote:
> On 12/11/2011, ik <idokan at ....> wrote:
>>
>> procedure foo(AClass : TStrings);
>> foo(MyStringList); // Will return an error that TStrings is expected ...
>>
>> I can not use TStringList as the parameter without casting it to TStrings.
>> But I do not understand why this limitation added. Can you please explain
>> it to me ?
>
> I ran into the exact same issue this week, and also can't understand
> why this is not allowed any more. It *is* allowed in Delphi (at least
> D7).
It's not allowed in Delphi in case of a var/out parameter. It's allowed in both FPC and Delphi in case of a value/const parameter.
> The other issue I have is passing a property value via a var or const
> parameter. I used this a lot in my code too, and it worked for years
> without problems. This again, is supported in Delphi too.
No, it is not allowed by Delphi (at least not passing a property to a var-parameter; passing it to a const parameter is allowed by both FPC and Delphi).
Jonas
More information about the fpc-pascal
mailing list