comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <see.reply.to@maps.futureapps.de>
Subject: Re: smart pointer dangerous (no -> operator)
Date: Sat, 17 Jan 2009 20:07:33 +0100
Date: 2009-01-17T20:07:33+01:00	[thread overview]
Message-ID: <49722c75$0$31341$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <c18df438-7a69-4c63-9015-d961a55c9144@v39g2000pro.googlegroups.com>

Maciej Sobczak wrote:
> On 16 Sty, 12:42, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
> 
>> Frequently overlooked, I think, Ada has nested scopes, useful
>> in many ways here.
> [...]
> 
> The problem is that in the majority of cases the whole point of
> creating something dynamically (rather than on the stack) is to use it
> in some other scope - outside of where it was created.

Yes, local objects do not always work, even if the location
is spanning vast areas of the program. While you can have scopes
nested in scopes nested in scopes next to a neighboring nested scope,
nicely making types and objects local or global as
desired, this is not always a (satisfactory) solution.

> In your example the only motivation for allocating the object
> dynamically would be to trade off stack space for heap space. Are
> there any others?

None that I can think of. But being able to confine objects to
scopes and at the same time  control their lifetimes using scopes
can make some tricky pointer programming patterns unnecessary that
might otherwise be necessary, namely in case you use an allocator
of a library level pointer type. (GNAT makes us prefer allocators
for larger objects because of an implementation choice, AFAIK...)



  reply	other threads:[~2009-01-17 19:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-16 10:04 smart pointer dangerous (no -> operator) Oliver Kowalke
2009-01-16 11:09 ` Dmitry A. Kazakov
2009-01-16 11:42   ` Georg Bauhaus
2009-01-16 12:43     ` Dmitry A. Kazakov
2009-01-16 21:21     ` Maciej Sobczak
2009-01-17 19:07       ` Georg Bauhaus [this message]
2009-01-16 11:46   ` Oliver Kowalke
2009-01-16 12:45     ` Dmitry A. Kazakov
2009-01-17  0:43   ` Brian Drummond
2009-01-17  9:28     ` Dmitry A. Kazakov
2009-01-16 20:08 ` Tero Koskinen
2009-01-16 21:16   ` Maciej Sobczak
2009-01-18 12:21 ` Samuel Tardieu
replies disabled

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