<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-07-28 12:40 GMT+02:00 Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><span style="color:rgb(34,34,34)">I don't see how you can solve nullable var parameters in native code.</span><br></div></div>
</blockquote><div><br></div><div>I'd like to present how TNullable<T> works in my implementation (compilable and runable program ;)</div><div><br></div><div><span style="font-size:12.8px">=== code begin ===</span><br></div><div><div>procedure Test1(var x: Integer);</div><div>begin</div><div> x := 1;</div><div>end;</div><div><br></div><div>procedure Test2(var x: TNullable<Integer>);</div><div>begin</div><div> x := 2;</div><div>end;</div></div><div><br></div><div><div>var</div><div> a: TNullable<Integer>;</div></div><div>begin</div><div> try</div><div> WriteLn(a.Value);</div><div> except</div><div> on E: EAccessViolation do</div><div> WriteLn(a.HasValue); // print false</div><div> end;</div><div> </div><div> a := 0;</div><div><br></div><div> WriteLn(a.HasValue); // print true</div><div><div> if a.HasValue then</div><div> begin</div><div> WriteLn(a.Value); // print 0</div><div> WriteLn(a^); // print 0</div><div> end;<br></div></div><div><br></div><div> Test1(a^);</div><div> WriteLn(a.Value); // print 1</div><div> Test2(a);</div><div> WriteLn(a.Value); // print 2</div><div>end.</div><div><span style="font-size:12.8px">=== code end ===</span><span style="font-size:12.8px"><br></span></div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Best regards,<br>Maciej Izak</div></div></div>
</div></div>