On 01/06/2021 22:40, Sven Barth via fpc-pascal wrote:
Am 01.06.2021 um 20:20 schrieb denisgolovan via fpc-pascal:
I am trying to implement Option type in FPC.
type
generic TOption = record
case IsSome:boolean of
true: ( some: T );
false: ();
end;
Well as already discover
I am using FPC v. 3.2.0 on both linux and windows.
I use Firebird as a database (not sure that this is important).
Say you write
var
AConnection:TIBConnection;
AQuery:TSQLQuery;
ATran:TSQLTransaction;
begin
// create the components...
// open a database...
// prepare a first query...
> Well as already discovered type like strings can not go into a "record case"
>
> But... The above record is anyway of constant size. I.e. the memory for
> the field is always included, even if it is not used.
>
> Since the "false" block is empty, you can do
>
> type
> generic TOption = recor
denisgolovan via fpc-pascal schrieb am
Mi., 2. Juni 2021, 13:28:
>
>
> > Well as already discovered type like strings can not go into a "record
> case"
> >
> > But... The above record is anyway of constant size. I.e. the memory for
> > the field is always included, even if it is not used.
> >
> >