On Thu, 28 Jul 2016, Maciej Izak wrote:

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

I don't see how you can solve nullable var parameters in native code.


I'd like to present how TNullable<T> works in my implementation (compilable
and runable program ;)

Yes, I remember you demonstrate it. But I think there are some caveats.


=== code begin ===
procedure Test1(var x: Integer);
begin
 x := 1;
end;

Assume a is null before the call to test1:

  test1(a);

1. What happens if this procedure is empty, i.e. no write is performed ?
   (or it is performed conditionally)
   On return, is a null or not ?

2. Assume your variable is null before the call to Test1.
   What is the value on entry into Test1 ? i.e. what happens if

   begin
     if X=0 then
       x:=1
     else
       X:=23;
   end

3. How do you detect an actual write ?

4. What happens if Test1 is an external C procedure ?

Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to