comp.lang.ada
 help / color / mirror / Atom feed
From: "John G. Volan" <johnvolan@sprintmail.com>
Subject: Re: Software landmines (was: Why C++ is successful)
Date: 1998/09/06
Date: 1998-09-06T00:00:00+00:00	[thread overview]
Message-ID: <35F377B2.456C6374@sprintmail.com> (raw)
In-Reply-To: m3g1egsug4.fsf@mheaney.ni.net

Matthew Heaney wrote:
> 
> Yes.  Far too few programmers use declare blocks and constant object
> declarations to simplify complex expressions.  Instead of
> 
> Op (Get_A (10), Get_B (X), Get_C (Y));
> 
> it's better to do
> 
> declare
>    A : constant Integer := Get_A (10);
>    B : constant Float := Get_B (X);
>    C : constant Boolean := Get_C (Y);
> begin
>    Op (A, B, C);
> end;

There's a subtle difference between these two examples:  In the latter
case, the local constant declarations will be elaborated in the
indicated order, so the function calls are going to be done
sequentially.  But in the former case, the language defines no
particular order of evaluation of the actual procedure parameters, so
these function calls might occur in any order.  A smart compiler for the
right kind of target machine may even be able to schedule these calls to
occur in parallel. 

...
> The "renames" clause is a binding operator in Ada (although technically
> it binds a name to an object, not a value).  A hip way to do the above
> directly in the language is
> 
> declare
>    A : Integer renames Get_A (10);
>    B : Float renames Get_B (X);
>    C : Boolean renames Get_C (Y);
> begin
>    Op (A, B, C);
> end;

I'm curious: Does this have the same effect as the above, i.e., are the
function calls forced into a sequential order?  Or is their evaluation
deferred until the aliases A, B, and C are actually used as parameters
to the Op call, in which case the aliased function calls get executed in
an undefined order?

-- 
indexing
   description: "Signatures for John G. Volan"
   self_plug: "Ex Ada guru", "Java 1.1 Certified", "Eiffelist wannabe"
   two_cents: "Java would be even cooler with Eiffel's assertions/DBC, %
              %generics, true MI, feature adaptation, uniform access, %
              %selective export, expanded types, etc., etc..."
class JOHN_VOLAN_SIGNATURE inherit SIGNATURE invariant
   disclaimer: not (opinion implies employer.opinion)
end -- class JOHN_VOLAN_SIGNATURE




  reply	other threads:[~1998-09-06  0:00 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-22  0:00 Software landmines (was: Why C++ is successful) dewar
1998-08-23  0:00 ` Dale Stanbrough
1998-08-23  0:00   ` dewar
1998-08-23  0:00   ` Andi Kleen
1998-08-24  0:00 ` Richard D Riehle
1998-08-25  0:00   ` dennison
1998-08-25  0:00   ` Andi Kleen
1998-08-25  0:00     ` Brian Rogoff
1998-08-28  0:00   ` Matthew Heaney
1998-08-28  0:00     ` Richard D Riehle
1998-08-29  0:00       ` Matthew Heaney
1998-08-29  0:00       ` Matthew Heaney
1998-09-06  0:00         ` John G. Volan [this message]
1998-09-07  0:00           ` Mats Weber
1998-09-07  0:00             ` dewarr
1998-09-08  0:00               ` Tucker Taft
1998-09-08  0:00                 ` Precalculation of parameters (was: Software landmines) dennison
1998-09-09  0:00                   ` Tucker Taft
1998-09-09  0:00                     ` dennison
1998-09-10  0:00                       ` Tucker Taft
1998-09-10  0:00                         ` dewarr
1998-09-16  0:00               ` Software landmines (was: Why C++ is successful) Matthew Heaney
     [not found]   ` <35eca5d9.4354839@news.geccs.gecm.com>
1998-09-01  0:00     ` Richard D Riehle
  -- strict thread matches above, loose matches on Subject: below --
1998-08-06  0:00 Why C++ is successful Robert Dewar
1998-08-07  0:00 ` harald.mueller
1998-08-07  0:00   ` Brian Rogoff
1998-08-07  0:00     ` Timothy Welch
1998-08-08  0:00       ` Robert Dewar
1998-08-08  0:00         ` Jeffrey C. Dege
1998-08-10  0:00           ` Laurent GUERBY
1998-08-12  0:00             ` Andy Ward
1998-08-14  0:00               ` Robert Dewar
1998-08-14  0:00                 ` Software landmines (was: Why C++ is successful) dennison
1998-08-15  0:00                   ` Thaddeus L. Olczyk
1998-08-16  0:00                   ` Jay Martin
1998-08-17  0:00                     ` Robert Dewar
1998-08-16  0:00                   ` Robert Dewar
1998-08-17  0:00                     ` dennison
1998-08-18  0:00                       ` adam
1998-08-19  0:00                         ` Tucker Taft
1998-08-19  0:00                           ` adam
1998-08-19  0:00                       ` ell
1998-08-19  0:00                         ` adam
1998-08-19  0:00                           ` Dan Higdon
1998-08-20  0:00                             ` adam
1998-08-20  0:00                               ` Dan Higdon
     [not found]                               ` <m33eagru5g.fsf@mheaney.ni.net>
1998-08-31  0:00                                 ` Frank Adrian
1998-08-31  0:00                                   ` Robert I. Eachus
1998-08-31  0:00                                     ` Biju Thomas
1998-08-31  0:00                                       ` Robert Martin
1998-09-01  0:00                                         ` Martin Dowie
1998-09-01  0:00                                       ` Robert I. Eachus
1998-09-02  0:00                                         ` dennison
1998-09-01  0:00                                   ` dewarr
1998-09-06  0:00                                 ` Jonathan Guthrie
1998-08-20  0:00                           ` Ell
1998-08-21  0:00                             ` Ell
1998-08-21  0:00                               ` Larry Brasfield
1998-08-21  0:00                                 ` Jeffrey C. Dege
1998-08-20  0:00                                   ` Phlip
1998-08-21  0:00                                   ` Larry Brasfield
     [not found]                                   ` <DOSXjHE9T6DM9Jw9nAyaPxfz@news.rdc1.bc.wave.home.com>
1998-08-22  0:00                                     ` dewar
1998-08-24  0:00                                       ` Martin Dowie
1998-08-24  0:00                                         ` Martin Dowie
1998-08-24  0:00                                           ` Mark A Biggar
1998-08-25  0:00                                             ` Martin Dowie
1998-08-25  0:00                                               ` Mark A Biggar
1998-08-26  0:00                                                 ` Martin Dowie
1998-08-25  0:00                                         ` adam
1998-08-24  0:00                                       ` dennison
1998-08-28  0:00                                         ` Matthew Heaney
1998-08-28  0:00                                           ` dennison
1998-08-30  0:00                                             ` Matthew Heaney
1998-09-06  0:00                                               ` John G. Volan
1998-08-31  0:00                                             ` Robert I. Eachus
1998-09-22  0:00                                       ` Charles H. Sampson
1998-08-21  0:00                                 ` Ell
1998-08-21  0:00                                 ` Bob Collins
1998-08-21  0:00                               ` John Goodsen
1998-08-21  0:00                                 ` Ell
1998-08-21  0:00                                   ` Ell
1998-08-19  0:00                         ` Charles Hixson
1998-08-20  0:00                         ` Gerry Quinn
replies disabled

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