comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@acm.org>
Subject: Re: Correct use of variants
Date: Mon, 07 Nov 2005 18:40:54 -0500
Date: 2005-11-07T18:40:54-05:00	[thread overview]
Message-ID: <ubr0w6n7d.fsf@acm.org> (raw)
In-Reply-To: dknag1$2u3$1@sunnews.cern.ch

Maciej Sobczak <no.spam@no.spam.com> writes:

> What is the correct way to achieve the declaration of A with the
> possibility of changing the discriminant later? One of the ways is to
> use *some* default value for the discriminant, 

That is the only way.

> but I might have difficulty deciding which value is better than the
> others for this role. 

It makes absolutely no difference. The syntax makes it look like you
are giving a default value to the discriminant, but it doesn't matter
what value you put; it will never be used.

> An arbitrary choice would create a misleading message to the reader
> that the particular value is considered to be "best" or "idle" or
> "starting" or whatever. 

I usually use:

type Foo_Type (descrim : Descrim_Type := Descrim_Type'first) is ...;

to indicate that I don't care what the default descriminant is.

> In addition, having a default value for the discriminant means that
> it's not obligatory to initialize the variable A while it's declared
> and I would like to keep this enforced.

Other posts have addressed this.

-- 
-- Stephe



  parent reply	other threads:[~2005-11-07 23:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-07 10:32 Correct use of variants Maciej Sobczak
2005-11-07 12:52 ` Jean-Pierre Rosen
2005-11-07 19:46 ` Jeffrey R. Carter
2005-11-07 23:40 ` Stephen Leake [this message]
2005-11-08  8:40   ` Maciej Sobczak
replies disabled

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