[fpc-pascal] parent class as a parameter type

ik idokan at gmail.com
Thu Nov 17 09:23:31 CET 2011


On Mon, Nov 14, 2011 at 23:03, Jonas Maebe <jonas.maebe at elis.ugent.be>wrote:

>
> 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.
>

Sorry for the late response, but why does out and var limit this issue ? I
understand that it does, but not the reason for it.


>
> > 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_______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111117/f6d0f3d7/attachment.html>


More information about the fpc-pascal mailing list