comp.lang.ada
 help / color / mirror / Atom feed
From: noc.near.net!inmet!spock!stt@uunet.uu.net  (Tucker Taft)
Subject: Re: User-defined assignment
Date: 17 Oct 92 23:32:09 GMT	[thread overview]
Message-ID: <1992Oct17.233209.16059@inmet.camb.inmet.com> (raw)

In article <1992Oct17.175730.17448@software.org> 
smithd@software.org (Doug Smith) writes:

> . . .
>Unfortunately, if user-defined assignment is not available,
>the guidelines explaining how to do memory management and
>garbage collection will be pretty sparce (as in Ada).  There
>is no need to explain the correct way to use a feature that
>doesn't exist.

I should probably clarify that Ada 9X *does* provide support
for user-defined initialization and finalization.  This is provided
for all limited types that are derivatives (direct or indirect)
of a predefined tagged type System.Controlled.  The operations
are called Initialize and Finalize, and are called at the 
"appropriate" time.  However, since this is restricted to "limited"
types, the user must define their own "Assign" procedure (or equivalent)
rather than rely on ":=".  

Therefore, this sort of user-defined assignment is 
supported, and Initialize and Finalize work correctly,
in the presence of exceptions and abort.  (What this means
is that Finalize is performed on an object if and only if Initialize
is performed on the object, and both Initialize and Finalize defer abort
until they complete, once they get started.)

However, a more complete kind of support for user-defined assignmet
would allow the user to simply use the ":=" operation, and have it invoke
user-defined code.  Unfortunately, this is only the tip of the iceberg.
Assignment is used implicitly in subprogram calls for by-copy parameters,
in creating aggregates, in explicit and implicit initialization, on
function return, in assignment for composite types,
etc.  By restricting user-defined finalization to
limited types, we avoid all of this hairy stuff, though the programmer
can still implement roughly equivalent operations using explicit 
subprograms.  E.g., Assign for assignment statements, Copy for
explicit copying, Make for constructing a value (like an aggregate),
and discriminants for controlling the Initialize procedure.

Of course, this is not as friendly or flexible as being able
to define ":=" for any type, and having it used automatically
everywhere it is appropriate.  However, it is significantly
easier to implement, while still giving the user the essential
capability of control over initialization and finalization, which
are sufficient to implement memory management and garbage collection.

So the question is how much Ada implementor expense and
effort is justified relative to the benefits of
the additional friendliness and flexibility.  Will this
have the tendency to make Ada compilers even more complex
and expensive, or is there some straightforward approach
that can be implemented at reasonable cost that will provide
sufficient benefit.

>Doug Smith
>smithd@software.org

S. Tucker Taft    stt@inmet.com
Ada 9X Mapping/Revision Team  ada9x-mrt@inmet.com (don't forget !topic)
Intermetrics, Inc.
Cambridge, MA  02138

             reply	other threads:[~1992-10-17 23:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-10-17 23:32 Tucker Taft [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-10-30  2:39 User-defined assignment Alex Blakemore
1992-10-29 18:20 Jack Beidler
1992-10-22 22:19 dog.ee.lbl.gov!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!darwin.su
1992-10-21 23:42 dog.ee.lbl.gov!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!rpi!bu.ed
1992-10-20 15:12 Rick Hudson
1992-10-19 14:13 Douglas N. Surber
1992-10-19  7:55 Dag Bruck
1992-10-19  7:31 Dag Bruck
1992-10-18 19:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!uvaarpa!soft
1992-10-17 17:57 dog.ee.lbl.gov!hellgate.utah.edu!caen!malgudi.oar.net!zaphod.mps.ohio-sta
1992-10-16 23:13 dog.ee.lbl.gov!hellgate.utah.edu!cs.utexas.edu!qt.cs.utexas.edu!news.Brow
1992-10-16 11:58 St ef Van Vlierberghe
1988-12-09 13:16 user-defined assignment Robert Firth
1988-12-09 20:35 ` David S. Rosenblum
replies disabled

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