On Fri, 25 Jun 2021, Dennis Lee Bieber via fpc-pascal wrote:
On Fri, 25 Jun 2021 16:12:41 -0600, Ryan Joseph via fpc-pascal
<fpc-pascal@lists.freepascal.org> declaimed
the following:
Is it possible something like this could work? Seems like it should but I get
an error (got MyRecord expected variant).
====================================
{$mode objfpc}
program unit_name;
type
TTuple = array of variant;
type
MyRecord = record
end;
Uhm, is there supposed to be some name designating storage space inside
that record declaration? Just my initial observation -- my Pascal
experience is Jensen&Wirth via UCSD (college, on LSI-11) and Alcor (on
TRS-80 Model 4).
var
t: TTuple;
r: MyRecord;
i: variant;
begin
t := [1,'string', r];
https://wiki.freepascal.org/Variant
"""
Values of any simple data type can be stored in a variant variable.
"""
... would seem to reject the use of a record type (as records are,
themselves, made up of other "simple data types").
It is not possible to do this unless you create some custom variant manager
that can handle this. But even so, you'd need to make it a pointer to a
record, as a variant has limited, fixed size.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal