comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Syntax for tagged record types
Date: 1997/05/26
Date: 1997-05-26T00:00:00+00:00	[thread overview]
Message-ID: <EAsop2.Jo9@world.std.com> (raw)
In-Reply-To: mheaney-ya023680002505971422590001@news.ni.net


In article <mheaney-ya023680002505971422590001@news.ni.net>,
Matthew Heaney <mheaney@ni.net> wrote:
>I say this because "discriminant" should mean "tag in a disjoint union." 
>Records are Cartesian product, and discriminated records are disjoint
>union.  And that's all discriminate record should mean.

It wasn't that way in Ada 83:

    type T(Discrim_1: Natural; Discrim_2: Character; Discrim_3: Boolean) is
        record
            Comp: String(1..Discrim_1) := (others => Discrim_2);
        end record;

I'm not sure whether you consider Discrim_1 as being a "tag in a
disjoint union," but Discrim_2 certainly isn't -- it's being used to
create an initial value.  Discrim_3 isn't either -- it isn't used inside
the record at all, and is merely a constant component of the record,
initialized at the point of each object declaration.

It seems to me that using discriminants inside an Initialize procedure
is a reasonable generalization of the Ada 83 concept illustrated by
Discrim_2.

>It's not unlike another sin commited by many Ada programmers.  That's when
>you use "and then" in predicates, when you really mean "and."  Many Ada
>programmers do this in a naive attempt at some sort of optimization, but it
>should only be used when you want to enforce an order dependence on
>evaluation of the parts of the predicate.

I agree with you about "and then".  But I don't buy the analogy with
discriminants.

- Bob




  reply	other threads:[~1997-05-26  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-24  0:00 Syntax for tagged record types Robert Dewar
1997-05-25  0:00 ` Matthew Heaney
1997-05-26  0:00   ` Robert A Duff [this message]
1997-05-27  0:00   ` Jon S Anthony
1997-05-27  0:00 ` Dale Stanbrough
1997-05-27  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