comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Discriminants constraining unconstrained array types
Date: Sat, 20 Oct 2001 21:43:48 GMT
Date: 2001-10-20T21:43:48+00:00	[thread overview]
Message-ID: <3BD1F00D.9EB26E5F@acm.org> (raw)
In-Reply-To: 3BD1B6F3.F90883D7@worldnet.att.net

James Rogers wrote:
> 
> 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.)
> >
> 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 am not aware of any compilers that generate unreasonable code for such
a construct. They all size objects of such a type based on the actual
subtype. A memory problem frequently occurs if the type has a default
discriminant and unconstrained objects are created, but the rule goes
beyond excluding such types/objects.

-- 
Jeff Carter
"Perfidious English mouse-dropping hoarders."
Monty Python & the Holy Grail



      parent reply	other threads:[~2001-10-20 21:43 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
2001-10-20 20:55   ` Larry Kilgallen
2001-10-20 21:43   ` Jeffrey Carter [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