From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: unconstrained records
Date: Sun, 22 Dec 2002 19:14:25 GMT
Date: 2002-12-22T19:14:25+00:00 [thread overview]
Message-ID: <wccn0mxeui6.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 3e0608b6.2790531@news.freenet.de
see@messagebody.com (Jan) writes:
> So when I write the following code (this one works), the string in
> "name" will ALWAYS occupy 15 bytes?
>
> subtype Max_Index is Natural range 0 .. 15;
>
> type Test (length : natural := 0) is
> record
> text : string (1..length);
> end record;
>
> name : Test;
On most Ada compilers, that's true. There are (or were) *some* Ada
compilers that used implicit heap allocation to implement this sort of
thing, so that when you assign a different-sized value, the old one gets
deallocated and the new one allocated. It's quite difficult to get the
heap-based implementation right. Consider renaming Name.Text(3), for
example.
- Bob
next prev parent reply other threads:[~2002-12-22 19:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-22 12:24 unconstrained records Jan
2002-12-22 13:52 ` SteveD
2002-12-22 18:54 ` Jan
2002-12-22 19:14 ` Robert A Duff [this message]
2002-12-27 20:34 ` Randy Brukardt
2002-12-23 4:30 ` SteveD
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox