From: Damien Carbonne <damien.carbonne@free.fr>
Subject: Re: Discriminants constraining unconstrained array types
Date: Sat, 20 Oct 2001 21:04:32 +0200
Date: 2001-10-20T21:02:04+02:00 [thread overview]
Message-ID: <3BD1CAC0.F5F48B14@free.fr> (raw)
In-Reply-To: 3BD1B6F3.F90883D7@worldnet.att.net
James Rogers a �crit :
> Matthew Woodcraft wrote:
> >
> > The following rule appears in the GNAT coding style guide:
> >
> > | Do not declare discriminated record types where the discriminant is
> > | used for constraining an unconstrained array type. (Discriminated
> > | records for a variant part are allowed.)
> >
> > Does anyone know a reason to avoid this feature of the language in
> > general, or is it more likely that there's just some issue with the
> > runtime or bootstrap behaviour which makes it inadvisable to use in the
> > compiler itself?
>
> I was not involved in the team that wrote this guideline.
>
> I can explain some of the problems with declaring discriminated
> record types used for constraining unconstrained array types.
>
> The first problems is memory usage. Take the following example:
>
> type Unconstrained_Type is array(Positive range <>) of Integer;
>
> type Inadvised_Record_Type (Max : Positive) is record
> Buffer : Unconstrained_Type(1..Max);
> end record;
>
I think what you explain further is right only if the declaration was:
type Inadvised_Record_Type (Max : Positive := 1) is record
Buffer : Unconstrained_Type(1..Max);
end record;
Note: "1" could be replaced by any other valid value.
The issue is with default values and declarations without constraint.
next prev parent reply other threads:[~2001-10-20 19:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-20 15:49 Discriminants constraining unconstrained array types Matthew Woodcraft
2001-10-20 17:39 ` James Rogers
2001-10-20 19:04 ` Damien Carbonne [this message]
2001-10-20 20:55 ` Larry Kilgallen
2001-10-20 21:43 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox