comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Future Ada language revisions?
Date: 1998/10/02
Date: 1998-10-02T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.98Oct2164706@spectre.mitre.org> (raw)
In-Reply-To: 6um7on$db5$1@nnrp1.dejanews.com

In article <6um7on$db5$1@nnrp1.dejanews.com> bpr5549@my-dejanews.com writes:

  > PS: In case anyone is wondering, my main peeve is the restriction
  > on out mode function parameters, which I just don't understand,
  > even when I'm trying to open minded. I have yet to hear a good
  > defense of this restriction, so if anyone has one, I'm all ears,
  > errr, eyes.

   I don't have strong feelings either way here, with a slight bias
toward allowing it in interfaces to make interfacing to C easier.
(Flame retardant:  Of course in C you can't have a function that
changes a function parameter, but the workaround it to require the
user to pass a pointer to an appropriate sized area.  You can, of
course, do exactly the same in Ada, but it means that the caller has
to be responsible for managing the memory.)

   But let me give the reasoning from the winning side:  There are
four cases where functions with side-effects are needed. 

   1) Memoizing functions, like random number generators.  This can be
done neatly enough in Ada, but in fact the twin requirements of Annex
A semantics and good performance make this a little tricky.  However,
users are unlikely to have to deal with any case as tough as the A.5.2
generators.  (The tough part is A.5.2(46): "Any storage associated with
an object of type Generator should be reclaimed on exit from the scope
of the object.")

   2) Functions which return more than one unconstrained value.  Again
Ada offers a disciplined way to do this since you can always declare a
record type and return that.  The known special cases in Ada 83 were
dealt with elsewhere, such as with Ada.Task_Identification.Task_ID.

   3) Functions which are operations of an object, with side effects
on that object.  The solution here is to make the complete object type
an access type, and hide that fact completely from outside users.  The
introduction of finalization in Ada 95 vastly simplifies the amount of
work to do this right in Ada 95.

   4) Interfacing to languages which permit functions to modify
parameters directly.  The prime case is PL/I.  (I like PL/I, I've
written a lot of code in PL/I, including parts of three Ada
compilers.)  Of course, PL/I is relatively much less popular than it
was when Ada 83 was standardized.

   So in every case where it is needed, the drawbacks are much less in
Ada 83.  On the other hand, if you do pull a fast one in Ada and write
a function with a side effect, READERS of the code will be very
surprised, and may miss the intent of the function, and certainly the
fact that such a call could have side effects or change its
parameters.  So allowing such functions has a distributed cost in
shops where no functions with side effects are ever written.
--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  parent reply	other threads:[~1998-10-02  0:00 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-27  0:00 Future Ada language revisions? bpr5549
1998-09-27  0:00 ` Larry Kilgallen
1998-09-27  0:00   ` Brian Rogoff
1998-09-28  0:00     ` dewarr
1998-09-28  0:00       ` Brian Rogoff
1998-09-29  0:00         ` Larry Kilgallen
1998-09-29  0:00         ` Michael F Brenner
1998-10-02  0:00           ` Fergus Henderson
1998-09-28  0:00     ` Michael F Brenner
1998-09-28  0:00       ` dewarr
1998-09-28  0:00   ` Arthur Evans Jr
1998-09-28  0:00     ` dewarr
1998-09-28  0:00 ` dewar
1998-10-05  0:00   ` Alfred Hilscher
1998-10-05  0:00     ` Tucker Taft
1998-10-05  0:00     ` dewarr
1998-10-06  0:00       ` Alfred Hilscher
1998-10-05  0:00     ` Brian Rogoff
1998-10-05  0:00       ` dewarr
1998-10-02  0:00 ` Robert I. Eachus [this message]
1998-10-03  0:00   ` Brian Rogoff
1998-10-05  0:00     ` dewarr
1998-10-04  0:00       ` Brian Rogoff
1998-10-05  0:00         ` Martin Dowie
1998-10-05  0:00           ` dewarr
1998-10-05  0:00           ` Niklas Holsti
1998-10-05  0:00             ` Martin Dowie
1998-10-06  0:00           ` r_barton1
1998-10-06  0:00           ` dennison
1998-10-06  0:00           ` dennison
1998-10-06  0:00             ` dewarr
1998-10-06  0:00               ` Martin Dowie
1998-10-06  0:00             ` Martin Dowie
1998-10-06  0:00         ` Matthew Heaney
1998-10-06  0:00     ` Robert I. Eachus
1998-10-06  0:00       ` Brian Rogoff
1998-10-07  0:00       ` dewarr
     [not found] ` <tgmF02yDo.A84@netcom.com>
1998-10-06  0:00   ` Matthew Heaney
1998-10-08  0:00 ` dennison
1998-10-08  0:00   ` Pat Rogers
1998-10-08  0:00   ` Brian Rogoff
1998-10-09  0:00     ` dennison
1998-10-16  0:00   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1998-10-21  0:00 Van Snyder
1998-10-22  0:00 ` Robert A Duff
1998-10-21  0:00   ` Brian Rogoff
1998-10-23  0:00     ` Robert I. Eachus
1998-10-29  0:00     ` Robert A Duff
1998-10-30  0:00       ` Brian Rogoff
replies disabled

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