[fpc-pascal] Chaining method calls

Michal Wallace michal.wallace at gmail.com
Tue Mar 24 14:39:05 CET 2020


Hi Ryan,

It's possible. Just change your declaration of `c`:

var c: TBase;

It still prints TMyClass at the end.

Of course, you're only going to have access to methods that are declared in
TBase.
You can also approach this sort of thing with interfaces...

-Michal  ( http://tangentstorm.com/ )


On Tue, Mar 24, 2020 at 4:08 AM Ryan Joseph via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:

> Free Pascal - General mailing list wrote
> > Is it possible to achieve this dynamically without resorting to type
> > casting? It feels like classes should have a builtin type for each class,
> > like TClassType, which similar to TObject.ClassType but is a compile time
> > type.
>
> I didn't think enough before sending this because this clearly isn't a
> compile time issue. Currently this probably isn't possible unless there is
> an "AnyClass" type or something like that. Not sure if that exists in
> Pascal
> but methinks not.
>
>
>
> -----
> Regards,
>         Ryan Joseph
> --
> Sent from: http://free-pascal-general.1045716.n5.nabble.com/
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200324/683fad46/attachment.html>


More information about the fpc-pascal mailing list