Am 02.06.2021 um 03:45 schrieb denisgolovan:
You simply can't use managed types in a variant clause and as T could be
a managed type the compiler does not allow it.
Well. I thought it should be precisely the case for variant clause to properly
handle.
Compiler knows IsSome field is used to de
> You simply can't use managed types in a variant clause and as T could be
> a managed type the compiler does not allow it.
Well. I thought it should be precisely the case for variant clause to properly
handle.
Compiler knows IsSome field is used to determine if some contains initialized
value
> On Jun 1, 2021, at 5:05 PM, Henry Vermaak wrote:
>
> https://en.wikipedia.org/wiki/Option_type
Yeah just use Nullable then since it sounds like that's the closest we're
going to get in FPC.
Regards,
Ryan Joseph
___
fpc-pascal maillist
On Tue, 1 Jun 2021, 23:39 Ryan Joseph via fpc-pascal, <
fpc-pascal@lists.freepascal.org> wrote:
>
>
> > On Jun 1, 2021, at 12:56 PM, denisgolovan
> wrote:
> >
> > That would limit supported types to class instances.
> > I'll like to avoid that.
> > Ideally TOption type should allow any type (prim
Am 01.06.2021 um 20:20 schrieb denisgolovan via fpc-pascal:
Hi all
I am trying to implement Option type in FPC.
type
generic TOption = record
case IsSome:boolean of
true: ( some: T );
false: ();
end;
However fpc just emits errors:
Error: Type parameters may require initial
Why `case`? You can make the same with a plain record:
type
generic TOption = record
IsSome: boolean;
some: T;
end;
вт, 1 июн. 2021 г. в 21:26, denisgolovan via fpc-pascal <
fpc-pascal@lists.freepascal.org>:
> Hi all
>
> I am trying to implement Option type in FPC.
>
> type
> gener
> You need to use a constraint like:
>
> type
> generic TOption = record
> case IsSome:boolean of
> true: ( some: T );
> false: ();
> end;
>
> Not sure why though.
>
> Regards,
> Ryan Joseph
That would limit supported types to class instances.
I'll like to avoid that.
Ideally TOption type sh
> On Jun 1, 2021, at 12:56 PM, denisgolovan wrote:
>
> That would limit supported types to class instances.
> I'll like to avoid that.
> Ideally TOption type should allow any type (primitives, strings, objects,
> class instances, etc).
What are you trying to make that requires a variant reco
> On Jun 1, 2021, at 12:20 PM, denisgolovan via fpc-pascal
> wrote:
>
> Hi all
>
> I am trying to implement Option type in FPC.
>
> type
> generic TOption = record
>case IsSome:boolean of
>true: ( some: T );
>false: ();
> end;
You need to use a constraint like:
type
generic
Hi all
I am trying to implement Option type in FPC.
type
generic TOption = record
case IsSome:boolean of
true: ( some: T );
false: ();
end;
However fpc just emits errors:
Error: Type parameters may require initialization/finalization - cannot be used
in variant records
Could an
10 matches
Mail list logo