comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Legit Warnings or not
Date: Sat, 23 Jul 2011 10:48:56 -0400
Date: 2011-07-23T10:48:56-04:00	[thread overview]
Message-ID: <wccei1haw87.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: j0d5vu$rfn$1@munin.nbi.dk

"Randy Brukardt" <randy@rrsoftware.com> writes:

> "Robert A Duff" <bobduff@shell01.TheWorld.com> 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



  reply	other threads:[~2011-07-23 14:48 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 22:30 Legit Warnings or not Anh Vo
2011-07-20 23:16 ` Robert A Duff
2011-07-21 18:43   ` Anh Vo
2011-07-23  0:26   ` Randy Brukardt
2011-07-23 14:26     ` Robert A Duff
2011-07-21  2:37 ` Jeffrey Carter
2011-07-21  9:50   ` Brian Drummond
2011-07-21 14:39     ` Dmitry A. Kazakov
2011-07-23  0:36       ` Randy Brukardt
2011-07-23  9:03         ` Dmitry A. Kazakov
2011-07-23 11:07           ` Simon Wright
2011-07-23 11:21             ` Dmitry A. Kazakov
2011-07-26 21:25           ` Randy Brukardt
2011-07-27  7:45             ` Dmitry A. Kazakov
2011-07-28  0:37               ` Randy Brukardt
2011-07-28  9:22                 ` Dmitry A. Kazakov
2011-07-28 14:22                   ` Robert A Duff
2011-07-28 14:41                     ` Dmitry A. Kazakov
2011-07-28 15:10                       ` Robert A Duff
2011-07-28 17:05                         ` Dmitry A. Kazakov
2011-07-28 23:32                           ` Randy Brukardt
2011-07-28 23:48                   ` Randy Brukardt
2011-07-29  6:57                     ` Simon Wright
2011-07-29 18:56                       ` Jeffrey Carter
2011-07-30  0:13                       ` Randy Brukardt
2011-07-29  7:41                     ` Dmitry A. Kazakov
2011-07-30  0:17                       ` Randy Brukardt
2011-07-30  8:27                         ` Dmitry A. Kazakov
2011-08-01 22:12                           ` Randy Brukardt
2011-08-02 10:01                             ` Dmitry A. Kazakov
2011-08-02 21:30                               ` Randy Brukardt
2011-08-03  9:01                                 ` Dmitry A. Kazakov
2011-08-03 20:35                                   ` Randy Brukardt
2011-08-04  8:11                                     ` Dmitry A. Kazakov
2011-08-05 23:57                                       ` Randy Brukardt
2011-08-06  8:23                                         ` Dmitry A. Kazakov
2011-08-08 21:30                                           ` Randy Brukardt
2011-07-23 14:32         ` Robert A Duff
2011-07-26 21:32           ` Randy Brukardt
2011-07-21 15:28     ` Adam Beneschan
2011-07-21 15:41       ` Robert A Duff
2011-07-21 20:12         ` Adam Beneschan
2011-07-23  0:31           ` Randy Brukardt
2011-07-21 17:40     ` Jeffrey Carter
2011-07-21 21:30       ` Brian Drummond
2011-07-21 21:54         ` Adam Beneschan
2011-07-22 10:16           ` Brian Drummond
2011-07-22 14:54             ` Adam Beneschan
2011-07-23  0:46             ` Randy Brukardt
2011-07-23  0:42         ` Randy Brukardt
2011-07-23  9:20           ` Niklas Holsti
2011-08-04  5:56             ` David Thompson
2011-07-23  9:24           ` Dmitry A. Kazakov
2011-07-23 12:36           ` Brian Drummond
2011-07-21 15:13   ` Robert A Duff
2011-07-23  0:52     ` Randy Brukardt
2011-07-23 14:48       ` Robert A Duff [this message]
2011-07-21 14:17 ` anon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox