From: Craig Carey <research@ijs.co.nz>
Subject: Re: How to define an array of a variant record type?
Date: Thu, 20 Nov 2003 23:02:42 +1300
Date: 2003-11-20T23:02:42+13:00 [thread overview]
Message-ID: <sn3prvon92b4b3pqn69f78l76cnphmh930@4ax.com> (raw)
In-Reply-To: ullqe6gpl.fsf@nasa.gov
On 17 Nov 2003 12:35:34 -0500, Stephen Leake wrote:
...
>change this to
>
>type Name_Value(Value_Type : Name_Value_Type := String_Type) is
>
>
>This seems very odd, but it works. It says to the compiler "let the
>discriminant change at runtime". Without the default value for the
>discriminant, the discriminant is _not_ allowed to change at runtime;
>it must be known at compile time.
http://www.adaic.org/standards/95aarm/html/AA-3-7.html
AARM 3.7 Discriminants
...
NOTES
28 50 If a discriminated type has default_expressions for its
discriminants, then unconstrained variables of the type are
permitted, and the values of the discriminants can be changed by an
assignment to such a variable. If defaults are not provided for the
discriminants, then all variables of the type are constrained,
either by explicit constraint or by their initial value; the values
of the discriminants of such a variable cannot be changed after
initialization.
28.a Discussion: This connection between discriminant defaults and
unconstrained variables can be a source of confusion. For Ada 95,
we considered various ways to break the connection between defaults
and unconstrainedness, but ultimately gave up for lack of a
sufficiently simple and intuitive alternative.
...
Presumably pesons could use Ada for 10 years without figuring that out,
except for slow Leake of information at comp.lang.ada.
----
Also there is the pragma Volatile trick (that won't run in GNAT 3.15p
due to the caching not going away): the discriminant is altered by
using X'Address or similar, and pragma Volatile suppresses the caching.
next prev parent reply other threads:[~2003-11-20 10:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-17 16:57 How to define an array of a variant record type? Harald Schmidt
2003-11-17 17:35 ` Stephen Leake
2003-11-20 10:02 ` Craig Carey [this message]
2003-11-17 17:37 ` Marius Amado Alves
2003-11-18 2:48 ` Steve
2003-11-18 9:04 ` Marius Amado Alves
2003-11-17 18:45 ` Rodrigo Garcia
2003-11-18 2:48 ` Steve
2003-11-18 17:48 ` Nick Roberts
2003-11-19 2:38 ` Steve
2003-11-19 8:11 ` Preben Randhol
2003-11-19 13:26 ` Rodrigo Garcia
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox