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

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Dec 8 22:45:11 CET 2018

On Sat, 8 Dec 2018 22:03:11 +0100 (CET)
Michael Van Canneyt <michael at freepascal.org> wrote:

> 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.

What has "as" to do with this thread?

> >> 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.

Yes, that's my point. Even if bitwise "and" would play a role here, the
precedence would still be the same.

> > 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 looked at it, but I still don't understand.
Perhaps you can explain the examples I gave?

// compiles, but should fail:
if o is TComponent and b then ; 
if o is TComponent or b then ; 

// compiles in fpc, but not in Delphi:
if b or o is TComponent then ;

// does not compile, correct
if b and o is TComponent then ;


More information about the fpc-pascal mailing list