<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-07-28 14:59 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 id="gmail-:21v" class="gmail-a3s gmail-aXjCH gmail-m15631967ebcfa01a">Because with the exception of the ^ operator, I see no need for any special<br>
constructions to achieve a "nullable type", except maybe some implicit<br>
constructor/destructor ?</div></blockquote></div><div class="gmail_extra"><br></div>procedure with var parameter is special case, we need somehow to perform backward compatibility and strong typing is the must. In the fact TNullable<Integer> is proxy type to field of ^Integer type. <span style="font-size:12.8px">^ operator exist to make life easier in comparison to C# implementation.</span></div><div class="gmail_extra"><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><span style="font-size:12.8px">"default field" is not necessary for nullable types but is extremely useful addition, more options and optimization for end user. We can exclude completely possibility of usage ^ operator for nullable types (^ for nullable type is j</span><span style="font-size:12.8px">ust my invention)</span><span style="font-size:12.8px">. In that case calling functions like test1 will be impossible. Just pure copy of Nullable types from C# -,- . So you are right - ascetic version of nullable type need only management operators (aka implicit constructor/destructor). Presented nullable type is not "pure" copy of C# implementation, presented above implementation has Pascal spirit and optimizations impossible to achieve in other languages. </span></div><div class="gmail_extra"><br></div><div class="gmail_extra"><span style="color:rgb(80,0,80);font-size:12.8px">btw. you can add </span></div><div class="gmail_extra"><span style="color:rgb(80,0,80);font-size:12.8px"><br></span></div><div class="gmail_extra">class operator Equal(A: TNullable<T>; B: T): Boolean;<span style="color:rgb(80,0,80);font-size:12.8px"><br></span></div><div class="gmail_extra"><br></div><div class="gmail_extra">to run this:</div><div class="gmail_extra"><br></div><div class="gmail_extra">if b = 0 then</div><div class="gmail_extra"> b:=1</div><div class="gmail_extra">else</div><div class="gmail_extra"> b:=23;</div><div class="gmail_extra">-- <br><div class="gmail_signature"><div dir="ltr"><div>Best regards,<br>Maciej Izak</div></div></div>
</div></div>