comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Why should the value for a discriminant be static?
Date: 09 Feb 2005 23:22:42 +0100
Date: 2005-02-09T23:22:42+01:00	[thread overview]
Message-ID: <plk6phwez1.fsf@sparre.crs4.it> (raw)
In-Reply-To: w9mdnb75ofjLypffRVn-tw@megapath.net

Randy Brukardt <randy@rrsoftware.com> writes:
> Jacob Sparre Andersen <sparre@nbi.dk> wrote in message
> news:rlszmyd956d.fsf@jacob.crs4.it...

> > Occasionally I run into the limitation that the value for a
> > discriminant be static.  I can design my way around the limitation
> > (when I remember it), but I would like to know the reason.  (also
> > because it might make it easier for me to remember the rule)
> 
> The only place I know of off-hand where there is such a limitation
> is with aggregates.

Yes.  That was also what I ran into today.

> There, the limitation is necessary so that compiler can know the set
> of components for the aggregate.

That makes sense.

> Otherwise, it would be impossible to check that components are
> given, which is *the* major benefit of using an aggregate over a
> series of component assignments.

Yes.

> I suppose such a check could be done at runtime, but that would be
> substantially less safe, as errors could exist in a program for a
> long time and occur only in unusual conditions after deployment.

True.  And although I think I also had the record components correct
the first time around (except for the non-static discriminant), the
changed code is probably safer.

> Anyway, does that answer your question, or was this in some other
> context?

It answers my question.  And I think it is enough to make me remember
this rule in the future.  Thanks.

Jacob
-- 
�By becoming continuous, war has fundamentally changed its character.
 In past ages, a war, almost by definition, was something that sooner
 or later came to an end, usually in unmistakable victory or defeat.�
                               -- Nineteen Eighty-Four, George Orwell
�I don't think you can win [the war on terror].�    -- George W. Bush



      parent reply	other threads:[~2005-02-09 22:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-09 14:30 Why should the value for a discriminant be static? Jacob Sparre Andersen
2005-02-09 18:34 ` Randy Brukardt
2005-02-09 20:16   ` Niklas Holsti
2005-02-10  0:19     ` Jeffrey Carter
2005-02-10 13:11       ` Niklas Holsti
2005-02-11  1:40         ` Jeffrey Carter
2005-02-11  7:52           ` Niklas Holsti
2005-02-09 22:22   ` Jacob Sparre Andersen [this message]
replies disabled

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