comp.lang.ada
 help / color / mirror / Atom feed
From: clay@titan.tsd.arlut.utexas.edu (Clay Johnson)
Subject: Re: limited private types, "=" operator
Date: 9 Aug 90 17:19:01 GMT	[thread overview]
Message-ID: <CLAY.90Aug9121901@clio.titan.tsd.arlut.utexas.edu> (raw)
In-Reply-To: erickson@cs.nps.navy.mil's message of 1 Aug 90 18:47:23 GMT

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

  parent reply	other threads:[~1990-08-09 17:19 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
1990-08-09 17:19 ` Clay Johnson [this message]
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