comp.lang.ada
 help / color / mirror / Atom feed
From: news.crd.ge.com!sunup!duncan@uunet.uu.net  (Art Duncan)
Subject: Re: and then
Date: 8 Apr 93 19:03:30 GMT	[thread overview]
Message-ID: <C56I9u.320@crdnns.crd.ge.com> (raw)

I think the question of "and then" was discussed in this group
about a year ago.  One question was whether or not an expression like

	if X /= 0 and Y/X > 3 then
	  ...
	end if;

should raise an exception if X = 0. If "and" is optimized to "and then"
it will not. However, the prevailing wisdom at that time was that the
above expression should raise an exception when X = 0.

There is also a matter of uniformity of the language. If B1, B2, and B3
are boolean vectors of the same dimension, the expression

	B1 and B2 and B3

will (and should) and them all together.

There is also the phrase " ... and the operands of an expression that does
not contain a short-circuit control form, are evaluated in SOME order that
is not defined by the language." This means that it is perfectly legal for
the compiler to generate code that evaluates

	X/Y > 3

before evaluating

	X /= 0

The term "some order" is used frequently in the LRM, with the implication
that any expression that depends, for its meaning, on the order of
evaluation is erroneous. Thus, if one wishes to force the order of
evaluation, the only linguistically correct method is to use the
short circuit forms.

Cheers,

	- Art Duncan
	  General Electric Company
	  Corporate Research and Development
	  Schenectady, NY 12301
	  duncan@crd.ge.com

             reply	other threads:[~1993-04-08 19:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-04-08 19:03 Art Duncan [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-04-12 18:38 and then Charles H. Sampson
1993-04-12 13:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!noc.n
1993-04-11  3:55 Michael Feldman
1993-04-10 19:52 Alex Blakemore
1993-04-10 15:43 Dik T. Winter
1993-04-10 15:36 Dik T. Winter
1993-04-10  9:39 munnari.oz.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!usenet
1993-04-10  1:03 Charles H. Sampson
1993-04-09 18:08 Dave Bashford
1993-04-09 14:06 Dan Rittersdorf
1993-04-08 22:35 Andrew Dunstan,,2285592,
1993-04-08 22:28 Alex Blakemore
1993-04-08 16:18 Charles H. Sampson
1993-04-08 15:34 Christopher J. Henrich
1993-04-08 12:21 enterpoop.mit.edu!usc!cs.utexas.edu!mars.tsd.arlut.utexas.edu!gardner
1993-04-07 22:58 Mark Lundquist
1993-04-07 21:07 Ray Harwood -- Data Basix: (602)721-1988
1993-04-07 16:21 Charles H. Sampson
1993-04-07 12:42 Robert Firth
replies disabled

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