comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Extension of non-limited type needs limited component
Date: Thu, 14 Nov 2002 05:43:47 -0600
Date: 2002-11-14T05:43:47-06:00	[thread overview]
Message-ID: <mailman.1037274242.18685.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 2dbd76f3.0211140126.5d233e41@posting.google.com

----- Original Message ----- 
From: "Mike" <michael.jackson5@virgin.net>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: November 14, 2002 3:26 AM
Subject: Re: Extension of non-limited type needs limited component


> I wrote
> 
> > > How do I extend a non-limited tagged type to add a limited component?
> 
> Jean-Pierre Rosen replied
> 
> > You can't. Make the original type limited.
> > The whole hierarchy has to be limited (or not limited, excluding adding a
> > limited element). The reason is that otherwise, you could end up trying to
> > assign a variable with a limited component.
> 
> Unfortunately I can't make the base type limited as it is a generic
> gui dialog base 'class'.
> 
> I understand that I would need to make the extended type limited to
> avoid the possible assignment to the limited component, but I cannot
> see why I should have to make the whole hierarchy limited.
> 
> How can assignment by upcasting the extended type possibly affect the
> limited component?
> 
Since the purpose of "limited" is to prevent having multiple copies of the
same object (e.g. an object of Ada.Text_IO.File_Type) wherein changing the
state of one of the copies is changed (e.g. by closing the file in the
previous example) would leave the other copy in an incorrect state,
allowing limited components in a non-limited record would violate this
principle.

On the other hand, if multiple access objects are used to designate the
same limited object, then changes to the state by reference through one
of the access objects will be reflected in all of the access objects
designating that limited object.

Of course, the specifier of a limited type may provide a Copy procedure
(e.g., with a declaration like
procedure Copy (From : My_Limited_Type; To : out My_Limited_Type);
In that case, the fact that use of a Copy procedure is required, rather
than a simple assignment, makes the user of the type aware, that he
is creating a new distinct object, not a new reference to an existing
object.




  reply	other threads:[~2002-11-14 11:43 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-13 10:03 Extension of non-limited type needs limited component Mike
2002-11-13 12:06 ` Jean-Pierre Rosen
2002-11-14  9:26   ` Mike
2002-11-14 11:43     ` David C. Hoos, Sr. [this message]
2002-11-14 12:33     ` Jean-Pierre Rosen
2002-11-14 14:27       ` Dmitry A. Kazakov
2002-11-14 19:25         ` Randy Brukardt
2002-11-15 10:04           ` Dmitry A. Kazakov
2002-11-15 22:09             ` Robert A Duff
2002-11-16 12:39               ` Dmitry A. Kazakov
2002-11-16 16:15                 ` Robert A Duff
2002-11-17 11:14                   ` Dmitry A. Kazakov
2002-11-17 12:26               ` Dale Stanbrough
2002-11-18 20:33                 ` Randy Brukardt
2002-11-18 21:48               ` Eric
2002-11-19 14:38               ` Eric
2002-11-15 21:41           ` Robert A Duff
2002-11-16  3:54             ` Randy Brukardt
2002-11-15  0:30         ` Robert A Duff
2002-11-15 10:22           ` Dmitry A. Kazakov
2002-11-15 21:56             ` Robert A Duff
2002-11-16 12:39               ` Dmitry A. Kazakov
2002-11-14 23:39     ` Robert A Duff
2002-11-15 21:51       ` Mike
2002-11-13 14:28 ` Robert A Duff
2002-11-14  9:33   ` Mike
2002-11-14  9:35     ` Lutz Donnerhacke
2002-11-14 21:41     ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2002-11-15 10:47 Grein, Christoph
2002-11-15 12:12 ` Dmitry A. Kazakov
2002-11-15 13:29   ` Jean-Pierre Rosen
2002-11-15 14:34     ` Dmitry A. Kazakov
2002-11-15 21:26     ` Robert A Duff
replies disabled

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