comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Shortcut logicals (was: Re: F200x )
Date: 01 Feb 2005 08:57:54 -0500
Date: 2005-02-01T08:57:54-05:00	[thread overview]
Message-ID: <wcc3bwgo00t.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1107259211.c5d05dcbf8695b73b67b208313002b2b@teranews

Martin Krischik <martin@krischik.com> writes:

> Christoph Grein wrote:
> 
> >  > Robert A Duff wrote:
> >  >
> >  > > And the syntax rules forbid mixing "and" and "and then" -- you have
> >  > > to use
> >  > > parens.??All?of?these?("and",?"and?then",?"or",?"or?else",?"xor") are
> >  > > lower precedence than most other operators in Ada.??So?you?can write:
> >  >
> >  > Are you sure? I did not find anything in the RM to support that. I
> > checked
> >  > both the RM and AARM:
> 
> > of course Robert is sure, if not, who else - you should know, he's
> > deeply involved in Ada development.

I wouldn't say "of course" -- after all, Martin Dowie pointed out that I
got the run time semantics wrong.  ;-)

> Ok you are right,  I am a just bit weak on names.
> 
> > See RM 4.4(2..7).
> 
> For our friends from comp.lang.fortran: You can read it up at
> http://www.adaic.com/standards/95lrm/html/RM-4-4.html:
>  
> > You'll find
> > relation and relation gives an expression,
> > relation and then relation also gives an expression.
> 
> > But there is no syntax rule to combine an expression with a relation.
> > You can only combine a parenthesized expression (a primary) with a
> > relation.
> 
> Sure, you are right. But that rule means that:
> 
>  X or Y and Z
> 
> is not valid either.

Yes, that's what it means.  You have to say:

    (X or Y) and Z
or
    X or (Y and Z)

in Ada.  In maths, folks usually presume that "and" has higher
precedence than "or".  I'm pretty happy with the Ada rule, though.  In
general, I don't think programming languages should use precedence and
associativity rules beyond the ones folks know by age 9.  Many people
disagree with that, though -- they think "extra" parens cause too much
clutter, and make the code hard to read.

- Bob



  parent reply	other threads:[~2005-02-01 13:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-01  8:49 Shortcut logicals (was: Re: F200x ) Christoph Grein
2005-02-01 11:43 ` Martin Krischik
2005-02-01 12:45   ` Adrien Plisson
2005-02-01 14:03     ` Martin Krischik
2005-02-01 14:56       ` Les
2005-02-01 16:57       ` Frank J. Lhota
2005-02-01 17:55       ` Dan Nagle
2005-02-01 18:25         ` James Giles
2005-02-01 13:57   ` Robert A Duff [this message]
2005-02-01 15:35     ` Shortcut logicals Jan Vorbrüggen
     [not found] <41f94cab$1@news1.ethz.ch>
     [not found] ` <INfKd.13707$bh6.378409@weber.videotron.net>
     [not found]   ` <nospam-6F7AE0.11340228012005@news.supernews.com>
     [not found]     ` <lqjnv01969glk2mbv1plvjdn5idkb1c3db@4ax.com>
     [not found]       ` <1107060103.157135.325010@z14g2000cwz.googlegroups.com>
     [not found]         ` <8u2pv0tdd9b1v689rtqc2c2tlm9pn9t1t6@4ax.com>
     [not found]           ` <1107085125.849687.318060@c13g2000cwb.googlegroups.com>
     [not found]             ` <1107096062.786125.100030@f14g2000cwb.googlegroups.com>
     [not found]               ` <10vq094k09igv3c@corp.supernews.com>
     [not found]                 ` <eudLd.43724$8u5.37685@bgtnsc04-news.ops.worldnet.att.net>
     [not found]                   ` <1107160100.162171.223490@f14g2000cwb.googlegroups.com>
     [not found]                     ` <cTxLd.126318$w62.46060@bgtnsc05-news.ops.worldnet.att.net>
     [not found]                       ` <xfKdnUflrtW3I2PcRVn-og@comcast.com>
     [not found]                         ` <rEzLd.68$xR1.54@bgtnsc04-news.ops.worldnet.att.net>
     [not found]                           ` <ON-dnSQzGfXOVWPcRVn-1A@comcast.com>
     [not found]                             ` <mXzLd.100$xR1.94@bgtnsc04-news.ops.worldnet.att.net>
2005-02-01  0:56                               ` Shortcut logicals (was: Re: F200x ) James Van Buskirk
2005-02-01  1:16                                 ` Robert A Duff
2005-02-01  8:08                                   ` Martin Krischik
2005-02-01  1:43                                 ` James Giles
2005-02-01  2:33                                   ` James Van Buskirk
2005-02-01  2:53                                     ` James Giles
2005-02-01  3:49                                       ` James Van Buskirk
2005-02-01  4:31                                         ` James Giles
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox