comp.lang.ada
 help / color / mirror / Atom feed
From: matthew_heaney@acm.org (Matthew Heaney)
Subject: Re: Limited types
Date: 1998/05/21
Date: 1998-05-21T00:00:00+00:00	[thread overview]
Message-ID: <matthew_heaney-ya023680002105982248330001@news.ni.net> (raw)
In-Reply-To: 3564E39E.B8D445B0@ececs.uc.edu


In article <3564E39E.B8D445B0@ececs.uc.edu>, Phani Putrevu
<pputrevu@ececs.uc.edu> wrote:

(start of quote)
How  exactly is limited type defined.. In the glossary of the on-line
RM, limited type is defined as a type for which the assignment operator
is not defined. What about the equality operator?  In the operators
section,  it is told that equality and inequality operators are
predefined for nonlimited types.  Does this follow from the assignment
operator not being allowed.
(end of quote)

Typically, you'd declare an abstract data type as limited, as in:

   type LT is limited private;

or 

   type LT is tagged limited private;

or

   type LT is abstract tagged limited private;

You can also declare a record as limited:

   type RT is 
      limited record
         ...
      end record;

Limited private types are used when you have an item which it doesn't make
sense to duplicate, ie

   type Bank_Account is tagged limited private;
...
   Matts_Money : Bank_Account;

I would love to be able to do this:

   Matts_Money := Matts_Money + Matts_Money;

but of course I don't think the bank would take too kindly to this sort of
thing!  That's why it's illegal (for limited types).

Equality isn't predefined for a limited type, but you can add one if it
makes sense for your abstraction:

   function "=" (L, R : Bank_Account) return Boolean;

Equality is predefined for a non-limited type.  The default definition is a
bit-wise compare, which very often is _not_ what you want, so even for
non-limited types, you typically override it.




  reply	other threads:[~1998-05-21  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-22  0:00 Limited types Phani Putrevu
1998-05-21  0:00 ` Matthew Heaney [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-02-24 16:51 limited types (Was: Records that could be arrays) Thierry Bernier
2006-02-24 21:57 ` Randy Brukardt
2006-02-25 11:06   ` Dmitry A. Kazakov
2006-02-25 15:05     ` Matthew Heaney
2006-02-26  9:00       ` Dmitry A. Kazakov
2006-02-26 18:20         ` Matthew Heaney
2006-02-26 20:52           ` Dmitry A. Kazakov
2006-02-26 22:07             ` Matthew Heaney
2006-02-27  9:11               ` Dmitry A. Kazakov
2006-02-27 14:34                 ` Georg Bauhaus
2006-02-27 16:05                   ` Dmitry A. Kazakov
2006-02-27 16:52                     ` Matthew Heaney
2006-02-27 20:21                       ` Dmitry A. Kazakov
2006-02-27 23:00                         ` Matthew Heaney
2006-02-28  9:39                           ` Dmitry A. Kazakov
2006-02-28 17:24                             ` Matthew Heaney
2006-02-28 19:06                               ` Dmitry A. Kazakov
2006-02-28 19:58                                 ` Matthew Heaney
2006-02-28 21:51                                   ` limited types Simon Wright
2006-03-01  1:59                                     ` Matthew Heaney
replies disabled

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