comp.lang.ada
 help / color / mirror / Atom feed
From: sampson@cod.NOSC.MIL (Charles H. Sampson)
Subject: Re: limited private types, "=" operator
Date: 4 Aug 90 00:01:13 GMT	[thread overview]
Message-ID: <2036@cod.NOSC.MIL> (raw)
In-Reply-To: 1152@cs.nps.navy.mil

In article <1152@cs.nps.navy.mil> erickson@cs.nps.navy.mil (David Erickson) writes:
>Is there any way to define "=" for a limited private type which is an
>access type (which may be null)?  The problem arises trying to test for
>null without producing an infinitely recursive definition.

     This is a special case of the problem of breaking the recursion when
defining an overloaded operator on a private type.  The LRM contains an
example, 7.4.2(13).  In that example, the private type was realized as a
named type (Integer) and the name was used to convert from the private
type to a type different from that of the function's arguments.  In your
case, the realization of your private type has no name, in the straight-
forward implementation, so you have to circle around the problem in order
to give it a name:

   ...
   TYPE Ltd_pvt IS LIMITED PRIVATE;
   ...
PRIVATE
   ...
   TYPE Type_name IS ACCESS List_link;
   TYPE Ltd_pvt IS NEW Type_name;
   ...
END PACKAGE ...;

PACKAGE BODY ...
   ...
   FUNCTION "="(L, R : Ltd_pvt) RETURN Boolean IS

   BEGIN
      ...
      IF Typ_name(L) = NULL THEN ...
      ...
   END "=";

                               Charlie Sampson

  parent reply	other threads:[~1990-08-04  0:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-08-01 18:47 limited private types, "=" operator David Erickson
1990-08-02  3:34 ` mackey
1990-08-02 17:46 ` David Kassover
1990-08-03 16:01   ` David Erickson
1990-08-04  0:01 ` Charles H. Sampson [this message]
1990-08-09 17:19 ` Clay Johnson
1990-08-10 16:20   ` David Erickson
  -- strict thread matches above, loose matches on Subject: below --
1990-08-02 13:44 "Norman H. Cohen"
replies disabled

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