From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ea0955083361ce29 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-22 11:15:02 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: unconstrained records User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Sun, 22 Dec 2002 19:14:25 GMT Content-Type: text/plain; charset=us-ascii References: <3e05aebf.3122500@news.freenet.de> <3e0608b6.2790531@news.freenet.de> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:32204 Date: 2002-12-22T19:14:25+00:00 List-Id: 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