comp.lang.ada
 help / color / mirror / Atom feed
From: dgibson@snoopy.cis.ohio-state.edu (david scott gibson)
Subject: Re: Q: on redefinition of "=
Date: 1996/04/01
Date: 1996-04-01T00:00:00+00:00	[thread overview]
Message-ID: <4jp05jINNqo6@snoopy.cis.ohio-state.edu> (raw)
In-Reply-To: Dp6wAp.6w5.0.-s@inmet.camb.inmet.com

In article <Dp6wAp.6w5.0.-s@inmet.camb.inmet.com>,
Tucker Taft <stt@henning.camb.inmet.com> wrote:
>david scott gibson (dgibson@aleutian.cis.ohio-state.edu) wrote:
>
>: Hi.  I'm overloading the = operation to return a non-boolean value for
>: a non-limited private type.  Is there any way in Ada95 to "hide" the
>: automatically defined = returning a boolean value?  Redefining =
>: returning a boolean type in the private section didn't seem to help.
>
>Presuming your private type is not a tagged type, you could
>override the predefined "=" operator with one declared as "abstract."
>For tagged types, this is only allowed if the type is itself abstract.
>But for untagged types, you can use "abstract" as a way of overriding
>a primitive operation in a way that makes it illegal to call it.

Yes.  Unfortunately it is a tagged type.

>On the other hand, it might be simpler to provide some definition 
>for "=" that returns Boolean, perhaps in terms of the one that 
>returns the non-boolean value (are you using tri-state logic?).

Actually, I would like to use the Boolean = and automatically defined
/= to privately implement my non-Boolean = and /=.  It's not tri-state
logic and, believe me, you really don't want to know about it :-).
Anyway, in the design I'm currently working with all types must
support automatic initialization and finalization (and thus are
controlled types) and have the primitive operation Swap.  Since I'd
like to be able to import Swap implicitly for all types, I'm deriving
all types from a common controlled base type with Swap as an abstract
primitive.  With this strategy, Ada's built-in scalars are not
composable and thus in place of Boolean, I'm offering up the
controlled type Bool (many apologies).  Bool is the alternative return
type here.  Ideally Bool would be a limited type, but then I can't
provide equivalents of the standard Boolean operations which must
return a non-limited type and := is convenient here.  (I'm painfully
aware of some of the negative implications of this stategy.)  Letting
the Boolean = show through the interface is a reasonable option, but
has a few negative consequences.  At this point I'm just trying to see
if there is a way to hide the Boolean =.  I'm beginning to suspect
not.

--
Dave
dgibson@cis.ohio-state.edu




  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 ` Tucker Taft
1996-04-01  0:00   ` david scott gibson [this message]
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
1996-04-01  0:00 ` Robert A Duff
1996-04-01  0:00   ` david scott gibson
1996-04-01  0:00     ` Robert A Duff
replies disabled

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