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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!nosc!cod!sampson From: sampson@cod.NOSC.MIL (Charles H. Sampson) Newsgroups: comp.lang.ada Subject: Re: limited private types, "=" operator Message-ID: <2036@cod.NOSC.MIL> Date: 4 Aug 90 00:01:13 GMT References: <1152@cs.nps.navy.mil> Reply-To: sampson@cod.nosc.mil.UUCP (Charles H. Sampson) Organization: Computer Sciences Corporation List-Id: 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