From: Mats Weber <Mats.Weber@elca-matrix.ch>
Subject: Re: Pb with use of redefined "=" operator
Date: 1998/11/04
Date: 1998-11-04T00:00:00+00:00 [thread overview]
Message-ID: <3640B520.D7BEEE72@elca-matrix.ch> (raw)
In-Reply-To: m3zpa860yd.fsf@mheaney.ni.net
Matthew Heaney wrote:
> ALWAYS import equality for any non-tagged formal type. In the data
> structure library I'm building, every private type is imported as
>
> generic
>
> type Item_Type is private;
>
> with function "="
> (L, R : Item_Type)
> return Boolean is <>;
> ...
> package ACL.Stacks.Adapters is ...
I would advise against this, because predefined equality will reemerge
in other situations, such as this:
type Pair is
record
X, Y : Item_Type;
end record;
"=" (Pair, Pair) will use the predefined equality on Item_Type, so that
you have to write a new "=" function for Pair. This makes it very hard
to check that the code is correct (i.e. every record/array declaration
that contains a generic formal type must have its own redefined "=").
My advice is that you must know about the reemergence problem and never
instantiate a generic with a type whose predefined "=" does not work.
You can often do this it using tagged types.
next prev parent reply other threads:[~1998-11-04 0:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-11-03 0:00 Pb with use of redefined "=" operator Fran�oise & Herv� BITTEUR
1998-11-04 0:00 ` Matthew Heaney
1998-11-04 0:00 ` Mats Weber [this message]
1998-11-05 0:00 ` Matthew Heaney
1998-11-05 0:00 ` dewarr
1998-11-05 0:00 ` Matthew Heaney
1998-11-06 0:00 ` dewarr
1998-11-09 0:00 ` Robert A Duff
1998-11-10 0:00 ` dennison
1998-11-10 0:00 ` Robert A Duff
1998-11-05 0:00 ` Mats Weber
1998-11-05 0:00 ` Matthew Heaney
1998-11-09 0:00 ` Robert A Duff
1998-11-09 0:00 ` Brian Rogoff
1998-11-10 0:00 ` Robert A Duff
1998-11-10 0:00 ` Robert I. Eachus
1998-11-04 0:00 ` Mats Weber
1998-11-04 0:00 ` Fran�oise & Herv� BITTEUR
1998-11-04 0:00 ` dewarr
1998-11-04 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