comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Prohibiting dynamic allocation for the given type
Date: Wed, 19 Mar 2008 20:43:56 -0400
Date: 2008-03-19T20:43:56-04:00	[thread overview]
Message-ID: <wcctzj2mdgz.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 83335709-e099-416b-9967-5ab6aa0aea11@i12g2000prf.googlegroups.com

Maciej Sobczak <see.my.homepage@gmail.com> writes:

> Is it possible to "prohibit" dynamic allocation for the given type?

I don't know of any simple way to do that.

> Let's suppose that I have a type which instances make sense only on
> the stack.

Could you please give some examples of such a type?

Somebody mentioned a lock, which I find only half convincing.
Any others?

>... I want to prohibit users from dynamically allocating
> instances of this type so that they don't get into troubles.
> Preferably at compile-time.
>
> My understanding is that it cannot be done (allocation is not
> considered to be a type's operation and there is no way to "hide" it
> from users - as is possible in C++), but I would like to have it
> confirmed.

Well, you can prohibit clients from creating any objects at all
(heap or stack) by using (<>) discrims, and not exporting any
constructor functions.  But that's not what you asked for.

- Bob



      parent reply	other threads:[~2008-03-20  0:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-18 21:30 Prohibiting dynamic allocation for the given type Maciej Sobczak
2008-03-19  3:06 ` gpriv
2008-03-19  8:24   ` Maciej Sobczak
2008-03-19 11:31     ` Georg Bauhaus
2008-03-19 13:13     ` gpriv
2008-03-19 13:54       ` Maciej Sobczak
2008-03-19 16:37     ` Eric Hughes
2008-03-20  0:48       ` Robert A Duff
2008-03-20 21:35         ` Eric Hughes
2008-03-19 22:17     ` Georg Bauhaus
2008-03-19 23:40       ` gpriv
2008-03-20 21:11       ` Maciej Sobczak
2008-03-19 14:38   ` Adam Beneschan
2008-03-19 15:43     ` gpriv
2008-03-19 14:12 ` Pascal Obry
2008-03-19 23:08   ` Randy Brukardt
2008-03-20 20:26     ` Simon Wright
2008-03-20 22:03       ` Eric Hughes
2008-03-21  1:04         ` Randy Brukardt
2008-03-20  0:43 ` Robert A Duff [this message]
replies disabled

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