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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!titan!clay From: clay@titan.tsd.arlut.utexas.edu (Clay Johnson) Newsgroups: comp.lang.ada Subject: Re: limited private types, "=" operator Message-ID: Date: 9 Aug 90 17:19:01 GMT References: <1152@cs.nps.navy.mil> Sender: news@titan.tsd.arlut.utexas.edu Organization: Applied Research Laboratories, UT Austin. In-reply-to: erickson@cs.nps.navy.mil's message of 1 Aug 90 18:47:23 GMT 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. > > The only solution that I am aware of is to use UNCHECKED_CONVERSION to > retype the access type during the test for null, but this is a hack. > Is there a cleaner solution? I have not done so, but you should be able to `dereference' the "=" that appears within your overloaded "=" function by using the dotted notation, prepending the package name STANDARD where you want the original interpretation. Of course, you must then use the functional rather infix notation: if STANDARD."="(POINTER,null) then ... I'm no Ada expert, but it's my understanding that the dot notation may always be used to avoid ambiguity and, specifically, unintentional recursion when overloading a subprogram or operator. In general this can be useful; depending upon your implementation, you may want both the original operator and the new operator (recursively) available at the same time. For instance, if your new operator is meant to compare two recursively defined structures, like binary trees, then you may wish to define the new operator recursively, while also refering to the original interpretation of the operator. Let me know if this works, Clay