From: Mats Weber <Mats.Weber@elca-matrix.ch>
Subject: Re: Q: Primitive operation of a type
Date: 1997/07/02
Date: 1997-07-02T00:00:00+00:00 [thread overview]
Message-ID: <33BA43CC.E27C69CC@elca-matrix.ch> (raw)
In-Reply-To: mheaney-ya023680000107972317060001@news.ni.net
Matthew Heaney wrote:
> This will dispatch on the tag of the O1 and O2, but only if O1 and O2
> have
> the same tag, which can't be determined until run-time. If the
> tag-check
> fails, then an exception is raised (I forget which, either
> Constraint_Error
> or Program_Error).
It's Constraint_Error.
> procedure P (O1, O2 : T1'Class) is
> begin
> if O1 = O2 then
>
> This will dispatch on the equality operator, if the tags are the same.
> If
> the tags are different, then obviously the objects can't be the same,
> so no
> exception is raised (thankfully) and the function just returns False.
I'm not so sure we should be thankful for this one. In the following
situation, for instance, you may want "=" to return True even it the tags are different:
type Root_Set is abstract tagged private;
type AVL_Tree_Set is new Root_Set with private;
type Boolean_Array_Set is new Root_Set with private;
A : AVL_Tree_Set;
B : Boolean_Array_Set;
procedure P (X, Y : Root_Set'Class) is
begin
if X = Y then ...
end P;
P(A, B);
now X => A and Y => B have different tags, but I would like "=" to return True
iff A and B have the same elements, not the same elements and implementation.
next prev parent reply other threads:[~1997-07-02 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-25 0:00 Q: Primitive operation of a type Van Snyder
1997-07-01 0:00 ` Matthew Heaney
1997-07-02 0:00 ` Mats Weber [this message]
1997-07-03 0:00 ` Matthew Heaney
1997-07-08 0:00 ` Mats Weber
1997-07-14 0:00 ` Matthew Heaney
1997-07-02 0:00 ` Martin C. Carlisle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox