comp.lang.ada
 help / color / mirror / Atom feed
From: "Jean-Pierre Rosen" <rosen@adalog.fr>
Subject: Re: Heterogenous array
Date: Wed, 3 Mar 2004 10:43:37 +0100
Date: 2004-03-03T10:43:37+01:00	[thread overview]
Message-ID: <rt942c.6qo.ln@skymaster> (raw)
In-Reply-To: _U71c.51050$mU6.207186@newsb.telia.net

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]


"Bj�rn Persson" <spam-away@nowhere.nil> a �crit dans le message de news:_U71c.51050$mU6.207186@newsb.telia.net...
>Steve wrote:
>> The way I look at it, the default descriminant is a way of telling the
>> compiler you may want to assign a record with a different discriminant value
>> to a record you have declared.  That way enough memory is allocated to hold
>> the largest variant.  If you don't give a default descriminant, that tells
>> the compiler you're going to explicitly select the variant for each record
>> you declare, so it can size each variant in the smallest allocation - with
>> the restriction that you cannot assign a different variant after the
>> declaration.
>
>Okay, after some experimentation I understand the difference, but I
>can't help thinking that it seems somewhat unlike Ada to say "make the
>discriminant immutable in all objects of this type" by not giving it a
>default value. Putting a "constant" somewhere would have been more
>intuitive.
Acutally, it's the other way round.

What you want to do is to be able to declare an unconstrained variable, i.e.:
V :  Parameter_Definition;

Since there is no discriminant constraint, the variable is not constrained to always have the same value of the discriminant.
However, a discriminant is used by the compiler to make address computations. It would be extremely dangerous to have an
uninitialized discriminant. Therefore, a declaration that does not specify discriminants is allowed only if there are default values
for the discriminants.

-- 
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





  reply	other threads:[~2004-03-03  9:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-01  1:53 Heterogenous array Björn Persson
2004-03-01  2:22 ` Steve
2004-03-01 16:48 ` Robert I. Eachus
2004-03-01 22:01   ` Björn Persson
2004-03-01 23:29     ` Randy Brukardt
2004-03-02  2:56       ` Robert I. Eachus
2004-03-02  3:13     ` Steve
2004-03-02 22:29       ` Björn Persson
2004-03-03  9:43         ` Jean-Pierre Rosen [this message]
2004-03-03 14:44           ` Björn Persson
2004-03-03 17:52             ` Jean-Pierre Rosen
replies disabled

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