2016-07-28 14:59 GMT+02:00 Michael Van Canneyt <mich...@freepascal.org>:

> Because with the exception of the ^ operator, I see no need for any special
> constructions to achieve a "nullable type", except maybe some implicit
> constructor/destructor ?
>

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. ^ operator
exist to make life easier in comparison to C# implementation.

"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 just my invention). 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.

btw. you can add

class operator Equal(A: TNullable<T>; B: T): Boolean;

to run this:

if b = 0 then
  b:=1
else
  b:=23;
-- 
Best regards,
Maciej Izak
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to