[fpc-devel] Strange behaviour of ;
Tomas Hajny
XHajT03 at mbox.vol.cz
Sat Oct 22 10:17:12 CEST 2005
Date sent: Sat, 22 Oct 2005 09:14:53 +0200
From: Florian Klaempfl <florian at freepascal.org>
To: XHajT03 at vol.cz,
FPC developers' list <fpc-devel at lists.freepascal.org>
Subject: Re: [fpc-devel] Strange behaviour of ;
> Tomas Hajny wrote:
> >>>Marc Weustink wrote:
> >>>
> >>>>It looks like "+ <some call>" is parsed wrong. The next "program"
> >>>>compiles fine.
> >>>
> >>>Well, the compiler/parser thinks you use the unary + operator which
> >>>it can safely throw away :) IIRC TP accepted the unary + operator
> >>>for any expression so we did.
> >>
> >>Delphi doesn't allow it. a single '+ <x>' is not changed implicitly
> >>to '0 + <x>' so that there is checking done instead of ignoring the
> >>the '+'.
> >
> >
> > TP/BP doesn't allow it either:
> >
> > Turbo Pascal Version 7.0 Copyright (c) 1983,92 Borland
> > International
> > T.PAS(3): Error 113: Error in statement.
> > + ParamStr(0);
>
> But it allows
> s:=+ParamStr(0);
> iirc
True. However, I think this is different from what Marc was
complaining about. Although I don't know the parser well, I believe
the compiler should be able to differentiate between these two
examples (unary +/- operator on the right side of an assignment,
which is OK, from unary +/- operator on the left side or before a
call, where there's probably no reason to accept it, because it
certainly looks like a programmer's error).
Tomas
More information about the fpc-devel
mailing list