Martin Frb schrieb:

Further, it appears that ^ has a higher precedence than  unary -

IMO pointer/address arithmetic (should) follows its own rules.
Unary - and @ should not be applicable to addresses. @ also is restricted to arguments which *do* have an address, i.e. not applicable to arithmetic expressions or properties.

Applicable binary operators depend on the type of both arguments, e.g. it's valid to subtract addresses (yielding an ordinal value), but adding addresses should be disallowed, while adding an ordinal value to an pointer is okay (yealding another address).


//  p:= -@i;   // if enabled, next line will crash

This should not compile, unary - is not applicable to addresses.

  writeln( -p^ ); // writes -99

Here ^ must take precedence, applied to an pointer/address.

"p+i^" is questionable, the only valid interpretation is (p+i)^.


IOW applicable operators and precedence depend on the type of the argument(s).

DoDi

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

Reply via email to