comp.lang.ada
 help / color / mirror / Atom feed
* Help: redefining equality
@ 1997-06-17  0:00 Paul Cohen
  1997-06-17  0:00 ` John Herro
  1997-06-17  0:00 ` Robert A Duff
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Cohen @ 1997-06-17  0:00 UTC (permalink / raw)



This question may be an oldie (and, I know, made obsolescent by Ada95),
but ...

What was the "standard trick" in Ada83 for being able to redefine
equality for non-private types (even though the language seemingly does
not allow it)?

(You may e-mail me your answer if you like.)

Thanks.

Paul




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help: redefining equality
  1997-06-17  0:00 Help: redefining equality Paul Cohen
@ 1997-06-17  0:00 ` John Herro
  1997-06-17  0:00 ` Robert A Duff
  1 sibling, 0 replies; 3+ messages in thread
From: John Herro @ 1997-06-17  0:00 UTC (permalink / raw)



Paul Cohen <paul.cohen@lmco.com> writes:
> What was the "standard trick" in Ada83
> for being able to redefine equality for
> non-private types (even though the language
> seemingly does not allow it)?

I don't know if this is a "standard trick," but the way I've always
done it in Ada 83 is to write, for example,

if Equal(X1, X2) then ...

and write my own function Equal.  The problem is that if X1 and
X2 belong to a non-private type, the language doesn't prevent
you from forgetting to call your own function and accidentally
writing

if X1 = X2 then ...

instead.

- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help: redefining equality
  1997-06-17  0:00 Help: redefining equality Paul Cohen
  1997-06-17  0:00 ` John Herro
@ 1997-06-17  0:00 ` Robert A Duff
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 1997-06-17  0:00 UTC (permalink / raw)



In article <33A6C7B8.796A@lmco.com>, Paul Cohen  <paul.cohen@lmco.com> wrote:
>What was the "standard trick" in Ada83 for being able to redefine
>equality for non-private types (even though the language seemingly does
              ^^^^^^^^^^^
>not allow it)?

I think you mean "non-limited".  The trick (first discovered by John
Goodenough, I believe) is to declare a generic package with a limited
private formal type.  Declare "=" on that.  Then pass in a non-limited
type.  Then reach into the instance to grab the "=" operator on the
non-limited actual type.

Yuck.

(E-mailed and posted.)

- Bob




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-06-17  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-17  0:00 Help: redefining equality Paul Cohen
1997-06-17  0:00 ` John Herro
1997-06-17  0:00 ` Robert A Duff

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