From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Unary operator after binary operator: legal or not? => Compiler Error
Date: Tue, 31 Jul 2007 11:05:05 -0400
Date: 2007-07-31T11:05:05-04:00 [thread overview]
Message-ID: <wccbqdsk40u.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: KdCri.384503$p47.38112@bgtnsc04-news.ops.worldnet.att.net
anon@anon.org (anon) writes:
> In <h%Bri.384485$p47.369566@bgtnsc04-news.ops.worldnet.att.net>, anon@anon.org (anon) writes:
>>This maybe a compiler error. It seams that my GNAT 2.1 from (NYC) as
>>well as my GNAT 4.3 (GNU) and my Adacore GNAT 2005 (GPL) all state
>>the same that it there is a "missing operand". But if you use the
>>following:
>> return "+"(Left) & "+"(Right);
>>or
>> return (+Left) & (+Right);
>>they both work
>>
>>From LRM 4.4 .. 4.5 and LRM 6.6 states that the unary functions can be
>>redefined. The reason I say this may be an compiler error is because
>>the following will still give the same error:
>>
>>Compiling: xyz.adb (source file time stamp: 2007-07-30 03:00:04)
>>
>> 1.
>> 2. function Xyz (Left, Right : in integer) return integer is
>> 3.
>> 4. begin -- Xyz
>> 5. if +Left <= +Right then
>> 6. return +Left * +Right;
>> |
>> >>> missing operand
>>
>> 7. end if;
>> 8. end Xyz;
>>
>
> Forgot to add, in my modified math version, if you replace the "+Right"
> with "+7" which is a simple_expression it still will give an error. And
> because you could replace the "+7" with "-7", for negative numbers,
> which is also a simple_expression you still get an error. This means you
> have found a compiler error!
>
> This needs to be reported!
If there's a bug, it's a bug in the language definition. ;-)
GNAT is correctly implementing the syntax rules, here.
"X * +7" and "X * -7" and "X * -Y" and so forth are
all illegal. See RM-4.4.
There is a similar example in RM-4.5(17), with the comment
"-- parentheses are necessary".
This has nothing to do with user-defined operators.
It's just the syntax rules -- defining your own
operators doesn't change the syntax.
- Bob
next prev parent reply other threads:[~2007-07-31 15:05 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-30 22:52 Unary operator after binary operator: legal or not? Jeffrey R. Carter
2007-07-30 23:39 ` Markus E.L.
2007-07-31 0:22 ` Adam Beneschan
2007-07-31 21:52 ` Jeffrey R. Carter
2007-07-31 8:01 ` anon
2007-07-31 8:16 ` Unary operator after binary operator: legal or not? => Compiler Error anon
2007-07-31 8:38 ` AW: Unary operator after binary operator: legal or not? => CompilerError Grein, Christoph (Fa. ESG)
2007-07-31 15:05 ` Robert A Duff [this message]
2007-07-31 15:39 ` Unary operator after binary operator: legal or not? => Compiler Error Dmitry A. Kazakov
2007-07-31 15:53 ` Robert A Duff
2007-07-31 17:02 ` Georg Bauhaus
2007-07-31 19:17 ` Adam Beneschan
2007-08-01 7:16 ` Maciej Sobczak
2007-08-01 15:23 ` Adam Beneschan
2007-07-31 20:59 ` Robert A Duff
2007-08-01 7:24 ` Georg Bauhaus
2007-08-01 8:02 ` Dmitry A. Kazakov
2007-08-01 8:17 ` AW: Unary operator after binary operator: legal or not? => CompilerError Grein, Christoph (Fa. ESG)
2007-08-01 10:10 ` Ian Clifton
2007-08-01 9:34 ` Unary operator after binary operator: legal or not? => Compiler Error Georg Bauhaus
2007-08-01 21:51 ` Jeffrey R. Carter
2007-07-31 17:52 ` Dmitry A. Kazakov
2007-08-02 20:44 ` Charles Lindsey
2007-08-03 7:48 ` Stuart
2007-08-03 7:51 ` Dmitry A. Kazakov
2007-07-31 23:22 ` anon
2007-08-01 0:13 ` Adam Beneschan
2007-08-01 6:20 ` Unary operator after binary operator: legal or not? => Illegal anon
2007-08-01 5:34 ` AW: Unary operator after binary operator: legal or not? => CompilerError Grein, Christoph (Fa. ESG)
2007-08-01 6:46 ` To := Grein, Christoph (Fa. ESG) anon
2007-08-01 7:11 ` AW: " Grein, Christoph (Fa. ESG)
2007-08-02 6:52 ` anon
2007-08-02 8:56 ` AW: " Grein, Christoph (Fa. ESG)
2007-08-02 22:29 ` Markus E.L. 2
2007-08-02 23:02 ` tmoran
2007-08-02 23:11 ` Ed Falis
2007-08-02 23:34 ` Markus E.L. 2
2007-08-03 4:42 ` AW: " Grein, Christoph (Fa. ESG)
2007-08-02 22:28 ` Markus E.L. 2
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox