[fpc-pascal] Option type
pascaldragon at googlemail.com
Wed Jun 2 07:30:19 CEST 2021
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 determine if some contains initialized value.
> On drop/free it would insert check:
> if IsSome then finalize(some);
No, because to use a field is not a requirement, it can be without a
name as well. Also the RTL would need to do checks each time the record
is assigned to another as there could be multiple managed entries.
It's not allowed for good reason.
More information about the fpc-pascal