[fpc-devel] Incomplete docs on operator precedence / Question about actual precedence

Martin Frb lazarus at mfriebe.de
Mon Feb 3 03:14:19 CET 2014


On 03/02/2014 01:42, Martin Frb wrote:
> http://www.freepascal.org/docs-html/ref/refch12.html#x120-13000012
>
> lists
>> Table 12.1: Precedence of operators
>>
>> Operator 	Precedence 	Category
>> ------------------------------------------------------------------------
>> 	
>> ------------------------------------------------------------------------
>> 	
>> ------------------------------------------------------------------------
>> Not, @ 	Highest (first) 	Unary operators
>> * / div mod and shl shr as << >> 	Second 	Multiplying operators
>> + - or xor 	Third 	Adding operators
>> = <> < > <= >= in is 	Lowest (Last) 	relational operators
>>
>
>
> This does not include:
> ^ deref
> - unary minus
> . accessing a member of a class/record (not unary)

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


program Project1;
operator - (a: PInteger) b: PInteger;
begin
   b := PInteger(-Integer(a));
end;

var
   p: PInteger;
   i: Integer;
begin
   i:= 99;
   p:=@i;
//  p:= - at i;   // if enabled, next line will crash
   writeln( -p^ ); // writes -99
   readln;
end.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140203/6ddf29ca/attachment.html>


More information about the fpc-devel mailing list