comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@dr_no.mitre.org (Robert I. Eachus)
Subject: Re: Assignment Overload in Ada-9X
Date: Thu, 25 Mar 1993 22:29:52 GMT
Date: 1993-03-25T22:29:52+00:00	[thread overview]
Message-ID: <EACHUS.93Mar25172952@dr_no.mitre.org> (raw)
In-Reply-To: beidler@guinness.cs.uofs.edu's message of 25 Mar 93 19:07:02 GMT

In article <11815@prijat.cs.uofs.edu> beidler@guinness.cs.uofs.edu (Jack Beidler) writes:

  > I recently received a copy of the "Ada 9X Project Report dated
  > February 1993.  On the top of page 48 in this report there is a
  > statement about overloading assignment, specifically,

  >	   ".., in the case of non-limited control types, assignment
  >	   can be redefined by the user."

  > I curious about the form of the overload.  Is it something like

  > procedure ":=" (Left : in out Some_Type ; Right : in   Some_Type) ?

  > or have I misread this statement?

     No, it is not.  And yes, you have misread the statement: control
should be controlled, but that is a detail.

     The way it works is that there are three operations inherited by
non-limited controlled types from the root type: INITIALIZE, FINALIZE
and CLONE.  (Well CLONE in ILS 1.2, I believe Tucker intends to change
the name.)  In any case, by redefining these operations when deriving
from CONTROLLED, you can obtain the effect of modifying assignment.
Of course, when defining these procedures, there are a lot of
operations on the new type that will cause indefinite recursion, etc.
But used properly, it allows for nice packaged abstractions where
assignment does all the special things required.  For example, it is
(relatively) easy to define a reference-counting type or a general
garbage collected type using this mechanism.

     Actually, now that this feature is relatively stable, I may post
those examples for experts to shoot at.  In either case it it about 20
lines of very sophisticated code that looks simple.  It might even be
a good idea to have both of these classes (oops! :-) as child packages
in the standard.


--

					Robert I. Eachus

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



      parent reply	other threads:[~1993-03-25 22:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-03-19 22:28 In favor of tagged types (was Classes versus tagged types was Ichibah flames, and flames out over, Ada 9X) John Goodsen
1993-03-21  3:20 ` Alex Blakemore
1993-03-25 19:07 ` Assignment Overload in Ada-9X Jack Beidler
1993-03-25 21:40   ` Mark A Biggar
1993-03-25 22:29   ` Robert I. Eachus [this message]
replies disabled

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