From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ace3fca092a457cd X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Unary operator after binary operator: legal or not? => Compiler Error Date: Tue, 31 Jul 2007 11:05:05 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1185894307 25653 192.74.137.71 (31 Jul 2007 15:05:07 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 31 Jul 2007 15:05:07 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:xULtiUAuz/J+lYUbi/9LRxTUgsU= Xref: g2news2.google.com comp.lang.ada:1290 Date: 2007-07-31T11:05:05-04:00 List-Id: anon@anon.org (anon) writes: > In , 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