[fpc-pascal] precedence "is" and "and"

Michael Van Canneyt michael at freepascal.org
Sat Dec 8 22:03:11 CET 2018



On Sat, 8 Dec 2018, Mattias Gaertner via fpc-pascal wrote:

> On Sat, 8 Dec 2018 21:23:57 +0100
> Marco van de Voort <fpc at pascalprogramming.org> wrote:
>
>> Op 2018-12-08 om 20:38 schreef Mattias Gaertner via fpc-pascal:
>> > According to the docs, the "is" operator is fourth level, the "and"
>> > is second level, so the "and" must be computed before the "is". But
>> > it seems fpc treats "is" and "and" as same level:

Hm.

In delphi, AS is second level, and 'is' is fourth level.

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Expressions_(Delphi)

If FPC does this differently, then I think this is an incompatibility.

>> 
>> logical (boolean) vs bitwise AND difference?
>
> I don't see where the bitwise should be involved here. There is no
> integer.
> The docs do not mention a different precedence lvl for logical/bitwise
> "and".

Because to the best of my knowledge, here isn't any difference in
precedence, so there is nothing to explain.

> It does not explain difference between "and" and "or".

Of course it does. See section on Logical operators

https://www.freepascal.org/docs-html/current/ref/refsu46.html

or boolean operators

https://www.freepascal.org/docs-html/current/ref/refsu47.html

I must confess it assumes that the reader knows what logical 'and' and 'or'
means, but someone who does not know that will probably not read the docs.
(although, he will also not understand "not" either and maybe read the docs...)

Michael.



More information about the fpc-pascal mailing list