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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news2.google.com!news.glorb.com!newsfeed-0.progon.net!progon.net!uucp.gnuu.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Unary operator after binary operator: legal or not? => Compiler Error Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Fri, 3 Aug 2007 09:51:59 +0200 Message-ID: <10t584xwu3tyb.1reyfdmws2k5k$.dlg@40tude.net> NNTP-Posting-Date: 03 Aug 2007 09:48:00 CEST NNTP-Posting-Host: 37baa5e2.newsspool2.arcor-online.net X-Trace: DXC=hZEOE]?AZL5T2Rfi67enW;^6ZC`4IXm65S@:3>?\:YaTQ@n2g? X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:1347 Date: 2007-08-03T09:48:00+02:00 List-Id: On Thu, 2 Aug 2007 20:44:49 GMT, Charles Lindsey wrote: > In Robert A Duff writes: > >>But don't you think: > >> X * -3 > >>ought to be legal (no user-defined operators in sight)? > > Interestingly, that example works in ALGOL 68, which generally speaking is > as pernickety a language as you are likely to get. > > --x works too. Essentially, all the monadic operators have a higher > preference than the dyadic ones. The Ada's rule is not about precedence it is about association. Unary minus does not associate with itself in Ada. This was a deliberate decision. > The only case where this turns out to be a little odd is > > -2^2 > > which is to be contrasted with the effect of > x-2^2 No problem, if you wanted -2**2 |= -(2**2), but 2**-2 |= 2**(-2), you would just extend the precedence model, see http://www.dmitry-kazakov.de/ada/components.htm#Parsers_etc (chapter 8.2.2) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de