comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Q: on redefinition of "=
Date: 1996/04/01
Date: 1996-04-01T00:00:00+00:00	[thread overview]
Message-ID: <Dp773I.9t4@world.std.com> (raw)
In-Reply-To: 4joui6INNqej@snoopy.cis.ohio-state.edu

In article <4joui6INNqej@snoopy.cis.ohio-state.edu>,
david scott gibson <dgibson@snoopy.cis.ohio-state.edu> wrote:
>Thanks for the suggestion.  However, I should have mentioned that the
>type for which I'm redefining equality (My_Type above) is indeed a
>tagged type.

Oh, sorry.

How about:

function "="(X, Y: My_Type'Class) return Boolean is abstract;
                          ^^^^^^

This does not override the predefined "=" for My_Type, but it will make
most calls of "=" ambiguous, and thus illegal.  The error message from
your compiler might not be as friendly as you would like, if you do
this.

And you still have to worry about reemergence of predefined "=",
which has been discussed at length in this newsgroup.

You could re-define the primitive "=" to raise an exception.  Then you
get run-time checking, which isn't quite as nice as compile-time
checking, but at least you get checking.  And, for tagged types,
predefined "=" doesn't "reemerge", which is nice.  I guess you could do
*both*.

>...  According to RM3.9.3(3), I believe I can only define an
>abstract subprogram as a primitive operation of a tagged type if the
>taggged type itself is abstract.

Correct.

>...  Thus this strategy doesn't seem to
>work.

Correct.

>...Admittedly what I'm trying to do is a bit strange, but I
>thought the rules for redefining the equality operator were intended
>to make something like this possible.  Perhaps this sort of thing was
>only intended for limited types.   Any other ideas anyone?

Making the type limited is often a good idea.  Do you *really* want ":="
on this type?  Would it not be better to have a Copy or Clone
subprogram, or some such thing?

- Bob




  reply	other threads:[~1996-04-01  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-30  0:00 Q: on redefinition of "= david scott gibson
1996-04-01  0:00 ` Robert A Duff
1996-04-01  0:00   ` david scott gibson
1996-04-01  0:00     ` Robert A Duff [this message]
1996-04-01  0:00 ` Tucker Taft
1996-04-01  0:00   ` david scott gibson
1996-04-01  0:00     ` Robert Dewar
1996-04-02  0:00       ` Mike Young
1996-04-02  0:00         ` Robert Dewar
1996-04-02  0:00           ` david scott gibson
1996-04-02  0:00             ` Robert A Duff
1996-04-02  0:00               ` david scott gibson
1996-04-02  0:00                 ` Robert A Duff
1996-04-02  0:00                   ` david scott gibson
1996-04-02  0:00             ` Robert Dewar
1996-04-03  0:00             ` Tucker Taft
replies disabled

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