From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Pb with use of redefined "=" operator
Date: 1998/11/05
Date: 1998-11-05T00:00:00+00:00 [thread overview]
Message-ID: <m3lnlq4fqd.fsf@mheaney.ni.net> (raw)
In-Reply-To: 71sc4h$6en$1@nnrp1.dejanews.com
dewarr@my-dejanews.com writes:
> In article <m3iugv70ke.fsf@mheaney.ni.net>,
> Matthew Heaney <matthew_heaney@acm.org> wrote:
>
> > It is for this reason that I always implement (the full view of) ADTs as
> > tagged, even if the partial view is not itself tagged.
>
>
> I think that this is definitely a wrong approach. The fact of the matter is
> that when you get to complex record types, it is rather rare to use the
> equality operator meaning just component equality. It seems quite unnecessary
> to introduce the overhead resulting from gratuitous tagging just in case this
> (mis)use occurs.
So you don't like this implementation of a stack?
type Stack_Type is private;
private
...
type Stack_Type is
tagged record
Items : Item_Array;
Top : Natural := 0;
end record;
The tagging here hardly seems gratuitous, as it's necessary to correct
what is arguably a flaw in the language!
> In practice I think that the problem is way overblown. Yes, it does cause
> some troubles, as we see from yet another thread started up on the subject,
> for those who don't know the language rules, but lots of things cause trouble
> if you don't know what you are doing!
I don't think this is an accurate comparison.
It is pure fantasy to think that every programmer is going to remember
the somewhat abstruse rules for what operators apply to a type when used
as a generic actual type.
The simplest approach is:
o write your ADTs so that equality always composes
o when importing a type as a generic formal, use only the equality
operator passed in, and not aggregate comparison
This way the code always works, and no one has to think - which is the
entire point of abstraction!
next prev parent reply other threads:[~1998-11-05 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 ` dewarr
1998-11-04 0:00 ` Tucker Taft
1998-11-04 0:00 ` Mats Weber
1998-11-04 0:00 ` Fran�oise & Herv� BITTEUR
1998-11-04 0:00 ` Matthew Heaney
1998-11-04 0:00 ` Mats Weber
1998-11-05 0:00 ` Matthew Heaney
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-05 0:00 ` dewarr
1998-11-05 0:00 ` Matthew Heaney [this message]
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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox