From: dmitry6243@my-deja.com
Subject: Re: Constructors/Destructors in Ada95
Date: Fri, 27 Oct 2000 08:46:55 GMT
Date: 2000-10-27T08:46:55+00:00 [thread overview]
Message-ID: <8tbfdv$601$1@nnrp1.deja.com> (raw)
In-Reply-To: 39F8A2CB.CA319F5@averstar.com
In article <39F8A2CB.CA319F5@averstar.com>,
Tucker Taft <stt@averstar.com> wrote:
> mark.biggar@trustedsyslabs.com wrote:
> > ...
> >
> > One of the problems with this proposal (redefineing ":=") is that
> > you would have to define Initialize, Adjust and Finialize anyway
> > as you need them to implement value parameter passing, temporary
> > creation and function return values correctly. Each of those is
> > like assingment, but not exactly the same being, built out of the
> > three primitives in different ways. So it makes more sense to just
> > define the three primitives and have the compiler generate
> > standard usage sequences then to redefine ":=" and have strange
> > and hard to understand things happen.
>
> This is part of the reason we did not allow the user
> to directly define ":=". Another important reason has to
> do with assignment of composite objects (e.g. records
> and arrays) containing objects with user-defined
> assignment. One desirable feature is that the assignment
> for a record, for example, is defined in terms of the
> assignment of its individual components. Unfortunately,
> there are cases of record assignment in Ada where
> the left-hand-side doesn't contain a component that
> the right-hand-side does. This happens if the left-hand-side
> is an unconstrained record with discriminants, and the
> right-hand-side happens to have different values for the
> discriminants than the values of the left-hand-side.
> As a result of the assignment, some components of the
> left-hand-side may disappear, and some may come into existence.
>
> For example:
>
> type Rec(B : Boolean := False) is record
> X : Cool_Controlled_Type;
> case B is
> when True =>
> Y : Fancy_Controlled_Type;
> when False =>
> Z : Another_Controlled_Type;
> end case;
> end record;
>
> R1 : Rec; -- Defaults to B => False
> R2 : Rec(B => True);
>
> ...
>
> R1 := R2; -- R1.Z disappears, R1.Y is created,
> -- R1.X overwritten
>
> It would be tricky at best to define how or whether
> user-defined ":=" for Cool_, Fancy_, and Another_Controlled_Type
> should be used in the above case.
[...]
I think that an assumption that Adjust should be generated from
user-defined ":=" is wrong, or at least very hard to implement.
IMO, used-defined ":=" should have no special semantic. It is not an
alternative to the copy constructor (= copy + Adjust).
The single link between them is that the default ":=" is generated as
Finalize, copy, Adjust.
In the given example, the compiler should simply ignore ":=" defined for
the types of Rec's components.
Another question is, whether copy constructor should be splitted into
block-copy and Adjust.
--
Regards,
Dmitry Kazakov
Sent via Deja.com http://www.deja.com/
Before you buy.
next prev parent reply other threads:[~2000-10-27 8:46 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-18 0:00 Constructors/Destructors in Ada95 Francois Godme
2000-10-19 0:00 ` Marin David Condic
2000-10-19 0:00 ` Ted Dennison
2000-10-19 0:00 ` tmoran
2000-10-19 0:00 ` Francois Godme
2000-10-19 0:00 ` Ted Dennison
2000-10-20 0:00 ` Tucker Taft
2000-10-20 0:00 ` Francois Godme
2000-10-21 0:00 ` Marin David Condic
2000-10-23 0:00 ` Francois Godme
2000-10-24 0:00 ` Ray Blaak
2000-10-25 0:00 ` Marin David Condic
2000-10-25 0:00 ` dmitry6243
2000-10-25 0:00 ` Pascal Obry
2000-10-26 0:00 ` dmitry6243
2000-10-25 0:00 ` mark.biggar
2000-10-26 11:44 ` dmitry6243
2000-10-26 13:25 ` Robert A Duff
2000-10-27 8:10 ` dmitry6243
2000-10-26 17:55 ` tmoran
2000-10-27 8:10 ` dmitry6243
2000-10-26 21:31 ` Tucker Taft
2000-10-27 8:46 ` dmitry6243 [this message]
2000-10-27 7:12 ` Ray Blaak
2000-10-25 0:00 ` Francois Godme
2000-10-27 18:11 ` Francois Godme
2000-10-30 11:36 ` Robert A Duff
2000-10-30 22:03 ` dale
2000-10-22 0:00 ` rwilson007007
2000-10-22 0:00 ` Francois Godme
2000-10-24 0:00 ` rwilson007007
-- strict thread matches above, loose matches on Subject: below --
2000-10-29 22:51 rwilson007007
2000-10-30 4:03 ` Ray Blaak
2000-10-30 12:13 ` Marin David Condic
2000-10-30 16:39 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox