Hello,

It seems that once a pointer has been assigned nil, it needs to be 
(re)allocated using new() before using it to (re)set its target:

...
p := nil;       // pointer to Integer
...
new(p) ; p^ := 1;

Is this hypothesis correct?

Use case: Linked List
nil is used in the "toNext" field of a list's last node, as a kind of end mark. 
When a new node is appended, I need to "renew" the toNext pointer to let the 
now forelast node hold a reference to the new one:

        // l is the list, n the new node
        // currently, l.toLast^.toNext = nil
        p := l.toLast;
        new(p^.toNext) ; p^.toNext^ := n;
        l.toLast^ := n;


Denis
________________________________

vit esse estrany ☣

spir.wikidot.com
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to