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,efc9f994d31d0d5e X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Limited initialization for non-limited types Date: Wed, 26 Mar 2008 10:02:46 -0400 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: pcls6.std.com 1206540166 4272 192.74.137.71 (26 Mar 2008 14:02:46 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 26 Mar 2008 14:02:46 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:9Ky/9xKIULSua6ullqGBhc27/eQ= Xref: g2news1.google.com comp.lang.ada:20580 Date: 2008-03-26T10:02:46-04:00 List-Id: Eric Hughes writes: > Is there any way of getting in-place initialization for non-limited > objects? No. We're thinking about doing that in GNAT as an optimization, but there's no way to force it. Note that assignment statements cannot use build-in-place in all cases. Perhaps you can get what you want by wrapping a nonlimited type in a limited record? > So here's the problem. I can't trace the Initialize call > "correctly". Consider the obvious initialization: > > T : Trace ; > A : X := Construct_X( T ) ; > > Because X is not a limited type, this code translates thus (in one > ordering): > > T : Trace ; > A : X ; > Initialize( A ) ; > Temp : X := Construct_X( T ) ; -- as if limited, constructed in > place > Initialize( Temp ) ; -- (*) > Finalize( A ) ; > A := Temp ; > Adjust( A ) ; > Finalize( Temp ) ; That's not a correct translation. For example, the line marked (*) will overwrite the result of Construct_X. To see what GNAT actually generates, use the -gnatD or -gnatG switch. But there's no guarantee it won't change in future versions! - Bob