From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7471346918e7cdd7,start X-Google-Attributes: gid103376,public From: matthew_heaney@acm.org (Matthew Heaney) Subject: Re: Limited types Date: 1998/05/21 Message-ID: #1/1 X-Deja-AN: 355462530 Content-Transfer-Encoding: 8bit References: <3564E39E.B8D445B0@ececs.uc.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Organization: Network Intensive Newsgroups: comp.lang.ada Date: 1998-05-21T00:00:00+00:00 List-Id: In article <3564E39E.B8D445B0@ececs.uc.edu>, Phani Putrevu 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.