Re: [fpc-pascal] Option type

2021-06-02 Thread Martin Frb via fpc-pascal
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

[fpc-pascal] is this a bug?

2021-06-02 Thread duilio foschi via fpc-pascal
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...

Re: [fpc-pascal] Option type

2021-06-02 Thread denisgolovan via fpc-pascal
> 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

Re: [fpc-pascal] Option type

2021-06-02 Thread Sven Barth via fpc-pascal
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. > > > >