comp.lang.ada
 help / color / mirror / Atom feed
From: "Les" <l.neilson@progs_acecad.co.uk>
Subject: Re: Shortcut logicals (was: Re: F200x )
Date: Tue, 1 Feb 2005 14:56:31 -0000
Date: 2005-02-01T14:56:24+00:00	[thread overview]
Message-ID: <cto5ao$sol$1@newsreaderg1.core.theplanet.net> (raw)
In-Reply-To: 1107266645.d89440009860d548c1e3d72cdc821e0c@teranews

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2296 bytes --]


"Martin Krischik" <martin@krischik.com> wrote in message
news:1107266645.d89440009860d548c1e3d72cdc821e0c@teranews...
> Adrien Plisson wrote:
>
> > Martin Krischik wrote:
> >> Christoph Grein wrote:
> >>>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. Not that I ever noticed - I would always use '()'
on
> >> such a term.
> >
> > it isn't valid. GNAT 3.15p says: mixed logical operators in expression.
> >
> > See RM Introduction - design goals (�7):
> > "error-prone notations have been avoided"
> >
> > and this construct is error-prone (especially if you are used to code
> > in other languages than Ada, since each language has its own different
> > operator precedence). the use of parenthesis clarifies the expression
> > and leverages any ambiguities.
>
> I fully agree with you here - and most Ada users will do as well. I would
> use () in C and C++ as well - for clarity.
>
> This is of corse a cross post with comp.lang.fortran and I wonder how they
> see our solution to the problem. Is it suitable for Fortran 2003 as well
or
> do they need another solution?


My own personal preference is for clarity of (a) readability and (b)
maintainablity.
Relying on my memory for operator precedence (or anything else, as anyone in
my family will testify) is unreliable. Hey I even have to look up the
relationship between TRUE and FALSE with 0 and 1 (or is it 1 and 0)
 :-)

So I use ( ) even if they are redundant.
I would tend to split a complex IF test into multiple tests - where
possible.
Situations where IF (X .and. Y) have side effects (X and/or Y being
functions say, either affecting the other) I also try to avoid and work
round another way.
My style may be "wordy", or niaive, or not to the taste of others, but as
long as I get correct and reasonably efficient code my employer and the
clients will be happy.

Les

>
> With Regards
>
> Martin
> -- 
> mailto://krischik@users.sourceforge.net
> http://www.ada.krischik.com





  reply	other threads:[~2005-02-01 14:56 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 [this message]
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
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