Variant part in objects?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Variant part in objects?

Free Pascal - General mailing list
Is there a reason that objects don't support variant sections like with records? Maybe they mess with the VMT table when virtual methods are added?

I just posted my "advanced objects" patch (https://bugs.freepascal.org/view.php?id=36350) and all it does is add "class operators" to objects but I was curious about the variant records because it appears to be the only other thing from records that aren't in objects.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Variant part in objects?

Gerhard Scholz
Do it like this:

type obj = object
                   vars : record
                                case boolean of
                                 ....
                              end ;
                  end ;

----- Original Message -----
From: "Ryan Joseph via fpc-pascal" <[hidden email]>
To: "FPC-Pascal users discussions" <[hidden email]>
Cc: "Ryan Joseph" <[hidden email]>
Sent: Sunday, November 24, 2019 3:18 PM
Subject: [fpc-pascal] Variant part in objects?


> Is there a reason that objects don't support variant sections like with
> records? Maybe they mess with the VMT table when virtual methods are
> added?
>
> I just posted my "advanced objects" patch
> (https://bugs.freepascal.org/view.php?id=36350) and all it does is add
> "class operators" to objects but I was curious about the variant records
> because it appears to be the only other thing from records that aren't in
> objects.
>
> Regards,
> Ryan Joseph
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal