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-Thread: 103376,c022fc5445abd13d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Discriminated types with default discriminants Date: 03 Nov 2005 18:08:05 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1131059285 25713 192.74.137.71 (3 Nov 2005 23:08:05 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 3 Nov 2005 23:08:05 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:6163 Date: 2005-11-03T18:08:05-05:00 List-Id: "Jeffrey R. Carter" writes: > There are 2 ways the compiler may implement this. Many compilers, > including GNAT, allocate enough storage for the largest value, and then > use parts of this storage depending on the current value of the > discriminant. If the largest value is too big, such a declaration > results in Storage_Error being raised. > > A few compilers will add a level of indirection, and store the > variable-sized stuff elsewhere, reallocating storage when the amount > available is not big enough. It is quite difficult to get the indirect approach to work right. Think about renaming a subcomponent of the thing, or taking 'Access of a subcomponent. Then the thing moves elsewhere in the heap when it grows. Bad news! I've seen compiler bugs in this area. > As with most implementation decisions, it's a trade off among > complexity, space, and time. Indeed. - Bob