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,5d4ade2fd8fd67c6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Legit Warnings or not Date: Sat, 23 Jul 2011 10:48:56 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <531193e0-3305-4292-9ed8-0176226c1d00@x12g2000yql.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1311432537 31948 192.74.137.71 (23 Jul 2011 14:48:57 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 23 Jul 2011 14:48:57 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:D261qdCpj+IAGhxP/tfbEIBwG0I= Xref: g2news2.google.com comp.lang.ada:21296 Date: 2011-07-23T10:48:56-04:00 List-Id: "Randy Brukardt" writes: > "Robert A Duff" wrote in message > news:wcc8vrrbrb6.fsf@shell01.TheWorld.com... > ... >> Implicit heap allocation could be a good feature in a different >> language, but then I'd want that language to allow: >> >> type Tree is tagged >> record >> Left, Right : Tree'Class; -- doubly illegal! >> end record; > > Yes, of course Ada should support this, too. ;-) As noted, it's not > particularly hard. Maybe in Ada 2020? ;-) ":=" and "=" need to walk the whole tree of subcomponents. Many folks (not me) would find that disconcerting. Unchecked_Deallocation would too, unless you use garbage collection. > Note that these sorts of allocations aren't really the same as heap > allocations -- their lifetime is similar to that of the secondary stack. Their lifetime is, but you want to use heap allocation because the sizes can change. Note that I'm assuming the Tag can change (which is highly not-Ada). E.g.: type This_Tree is new Tree with ...; type That_Tree is new Tree with ...; X : Tree'Class; X := This_Tree'(...); X.Left := This_Tree'(...); X.Left := That_Tree'(...); Or are you suggesting that you just keep growing the secondary stack? I don't like memory leaks. > Janus/Ada does allocate them on the heap (with them being deallocated when > scope goes away), but I've been thinking about ways to reduce/eliminate > that. One obvious idea is to allocate the initial sizes off of the secondary > stack, and only allocate from the heap if they get bigger via assignment in > a different master (which is fairly rare). Not sure if that would save > enough to be worth the extra complication. - Bob