[fpc-devel] Incomplete docs on operator precedence / Question about actual precedence
    Hans-Peter Diettrich 
    DrDiettrich1 at aol.com
       
    Mon Feb  3 10:42:04 CET 2014
    
    
  
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:= - at 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
    
    
More information about the fpc-devel
mailing list