<div dir="ltr"><div>Why `case`? You can make the same
with a plain record:</div><div><br></div><div>
type<br>
generic TOption<T> = record<br>
IsSome: boolean;<br>
some: T;<br>
end;
</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">вт, 1 июн. 2021 г. в 21:26, denisgolovan via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all<br>
<br>
I am trying to implement Option<T> type in FPC.<br>
<br>
type<br>
generic TOption<T> = record<br>
case IsSome:boolean of<br>
true: ( some: T );<br>
false: ();<br>
end;<br>
<br>
However fpc just emits errors:<br>
Error: Type parameters may require initialization/finalization - cannot be used in variant records<br>
<br>
Could anybody suggest some sane workaround for the problem?<br>
<br>
-- Regards,<br>
Denis Golovan<br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br>
<a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" rel="noreferrer" target="_blank">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Victor Matuzenko (Виктор Матузенко)<br></div></div></div></div>