comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Controlled types and exception safety
Date: Tue, 6 Dec 2005 22:20:18 +0100
Date: 2005-12-06T22:20:10+01:00	[thread overview]
Message-ID: <13xang4fkhnjw.g2203e2pgmv8$.dlg@40tude.net> (raw)
In-Reply-To: IaOdnUGlFKBcewjeRVn-vA@megapath.net

On Tue, 6 Dec 2005 13:34:29 -0600, Randy Brukardt wrote:

> This was the original idea for Ada 95, but it doesn't work. That's because
> the object on the left-hand side may come into existence because of the
> outer assignment, or disappear because of the assignment. The beauty (and
> curse) of Adjust is that it can be called by itself when needed, or with an
> appropriate Finalize.
> 
> You can't, in general, read the object that you're assigning into. That
> means that user-defined assignment in Ada can never be as powerful as that
> in other languages (unless you somehow prevent the types from being used in
> discriminant-dependent components - which would probably be a generic
> contract problem).
>
> For an another explanation of this, see ARM 7.6(17.a-17.h).
> http://www.adaic.com/standards/95aarm/html/AA-A-5-3.html
> 
> The other issues are solveable, but this one is not.

The question is at which cost. We could consider assignment composed out of 
two components. For any type T:

type T'Assignment_Data is tagged limited null record;
  -- predefined and can be extended

function T'Preassign (Left : in out T; Right : T)
   return T'Assignment_Data'Class;
procedure T'Postassign
   (Left : in out T; Right : T; Data : T'Assignment_Data'Class);
 
First T'Preassign is called. It can look at the left side, back up 
everything it needs in the result. It could even make rendezvous with the 
task components of Left, which is impossible now. Then the left side is 
finalized, the discriminants and constraints are set to ones of Right, some 
components are constructed and T'Postassign is called. Its parameter Data 
carries what T'Preassign has returned. After completion of T'Postassign 
Data is destroyed.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2005-12-06 21:20 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-30 13:57 Controlled types and exception safety Maciej Sobczak
2005-11-30 15:06 ` Dmitry A. Kazakov
2005-11-30 16:19   ` Maciej Sobczak
2005-12-01  0:05     ` Stephen Leake
2005-12-01  9:21     ` Dmitry A. Kazakov
2005-12-01 10:46       ` Maciej Sobczak
2005-12-01 15:08         ` Dmitry A. Kazakov
2005-12-02  4:17           ` Randy Brukardt
2005-12-02  9:29             ` Maciej Sobczak
2005-12-02 18:12               ` tmoran
2005-12-02 19:15                 ` Robert A Duff
2005-12-02 21:42                   ` tmoran
2005-12-06  9:00                     ` Maciej Sobczak
2005-12-06  9:50                       ` Dmitry A. Kazakov
2005-12-06 18:34                         ` Jeffrey R. Carter
2005-12-06 19:34                           ` Randy Brukardt
2005-12-06 21:20                             ` Dmitry A. Kazakov [this message]
2005-12-07  1:57                             ` Jeffrey R. Carter
2005-12-08  0:50                               ` Randy Brukardt
2005-12-08 19:37                                 ` Jeffrey R. Carter
2005-12-09  2:36                                   ` Randy Brukardt
2005-12-09  6:33                                     ` Jeffrey R. Carter
2005-12-09 20:35                                       ` Randy Brukardt
2005-12-10  7:53                                         ` Jeffrey R. Carter
2005-12-06 20:43                           ` Dmitry A. Kazakov
2005-12-07  2:00                             ` Jeffrey R. Carter
2005-12-07 10:01                               ` Dmitry A. Kazakov
2005-12-02 23:21             ` Robert A Duff
2005-11-30 17:46 ` Jean-Pierre Rosen
2005-11-30 21:02 ` Jeffrey R. Carter
2005-11-30 22:06   ` Björn Persson
2005-11-30 23:52     ` Randy Brukardt
2005-12-01  5:26     ` Jeffrey R. Carter
2005-12-02 23:51       ` Robert A Duff
2005-12-06 11:41   ` Peter C. Chapin
2005-12-06 12:50     ` Jean-Pierre Rosen
2005-12-06 13:06     ` Dmitry A. Kazakov
replies disabled

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