Prince Riley wrote:
Hello,
I had a chance to go to a reference and check on what the reserved word
'nil' , a special constant, seems to mean. According to the Object
Pascal manual (Borland) ...
"The reserved word nil is a special constant that can be assigned to any
pointer. When nil is assigned to a pointer, the pointer doesn't
reference anything."
Since a pointer is a memory address value, then the interpretation of
the statement "nil +1" would mean for p to point at the very next valid
address above the lowest memory address 'p' can hold.
That is an "interesting" interpretation of "doesn't reference anything".
There is no guarantee that nil is address 0, although it may be so in
any available compiler -- at least, any compiler targetting an
architecture that does not have usable memory at address 0. Nil doesn't
point at anything. It's an undefined address.
So it would
appear that 'p := nil + 1' should not compile or work.
That would be reasonable - although if nil /was/ 0, then nil+1 would be
defined for any given pointer type, and a compiler /could/ make a stab
at compiling it -- but probably /should not/. Because what would "1 more
than undefined" mean?
FP
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal