[fpc-devel] Incomplete docs on operator precedence / Question about actual precedence
Sven Barth
pascaldragon at googlemail.com
Mon Feb 3 15:41:33 CET 2014
Am 03.02.2014 14:52, schrieb Martin Frb:
> On 03/02/2014 10:48, Sven Barth wrote:
>>
>> So unary minus (and also unary plus which is a valid operator as
>> well!) binds stronger than multiplication.
>
> Just using -al
>
> c := -a *b;
> c := (-a) *b;
> c := -(a *b);
>
> The unary - is applied first. Though it makes no difference to the
> result.
>
> However with the overloaded operators, it may make a difference....
FPC uses the unary operator first as the parsing of operators is done at
a different part than the resolution to overloaded operators. Only
exception is mode ISO (or more precisely modeswitch ISOLikeUnaryMinus)
where the unary operator has the same precedence as the binary one
(don't know though whether the unary plus is respected here as well...)
Regards,
Sven
More information about the fpc-devel
mailing list