comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: subprogram must not be deeper than access type
Date: Mon, 26 Sep 2011 11:25:47 +0200
Date: 2011-09-26T11:25:48+02:00	[thread overview]
Message-ID: <4e80451b$0$6550$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <wccd3eothjf.fsf@shell01.TheWorld.com>

On 25.09.11 23:53, Robert A Duff wrote:

> It's really annoying that in Ada you can't write a small example program
> (with a single compilation unit in a single file) that has multiple
> library-level things.  If I ran the circus, there would be no library
> subprograms.  The main procedure would be declared inside a library
> PACKAGE.

It's worth mentioning, I think, that one source text for a single
compilation in a single file can be submitted to GNAT, such that
at the same time it also removes the specific accessibility problem
that Natasha's example exhibits.  To translate with GNAT, switch -z
is required.  Do other compilers support "main packages", too?

with String_Builder_Types;

package Main is
    use String_Builder_Types;

    function Builder (Depth : Positive) return Typ'Class;

    Output : String_Builder_Types.Non_Generic (Builder'Access);
end Main;

package body Main is

    function Builder (Depth : Positive) return Typ'Class is
       pragma Unreferenced (Depth);
    begin
       return String_Builder_Types.Empty_Typ;
    end Builder;

begin
    null;  --  or actually, real code.
end Main;

package String_Builder_Types is

    type Typ is tagged private;
    Empty_Typ : constant Typ;

    type Func is
        access function (Depth : Positive) return Typ'Class;

    type Non_Generic (Builder : Func) is tagged null record;
private
    type Typ is tagged null record;
    Empty_Typ : constant Typ := Typ'(null record);
end String_Builder_Types;



  reply	other threads:[~2011-09-26  9:25 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-25  9:02 subprogram must not be deeper than access type Natasha Kerensikova
2011-09-25 14:04 ` Oliver Kleinke
2011-09-26  9:35   ` Natasha Kerensikova
2011-10-03 23:30   ` Yannick Duchêne (Hibou57)
2011-10-03 23:39     ` Adam Beneschan
2011-10-04  0:52       ` Yannick Duchêne (Hibou57)
2011-10-04  1:48         ` Yannick Duchêne (Hibou57)
2011-09-25 14:23 ` Robert A Duff
2011-09-25 15:03 ` georg bauhaus
2011-09-26  9:45   ` Natasha Kerensikova
2011-09-26 13:43     ` Robert A Duff
2011-09-26 14:20       ` Dmitry A. Kazakov
2011-09-26 16:15         ` Robert A Duff
2011-09-26 19:30           ` Dmitry A. Kazakov
2011-09-27  0:41             ` Robert A Duff
2011-09-27  8:58               ` Dmitry A. Kazakov
2011-10-04  4:19               ` Yannick Duchêne (Hibou57)
2011-09-27  5:50             ` J-P. Rosen
2011-09-27  7:52               ` Dmitry A. Kazakov
2011-10-04  4:26                 ` Yannick Duchêne (Hibou57)
2011-10-04  7:58                   ` Dmitry A. Kazakov
2011-10-04 15:10                     ` Georg Bauhaus
2011-10-04 15:34                       ` Dmitry A. Kazakov
2011-10-04 15:49                         ` Yannick Duchêne (Hibou57)
2011-10-04 16:04                           ` Dmitry A. Kazakov
2011-10-04 15:44                       ` Yannick Duchêne (Hibou57)
2011-10-04 16:05                         ` Georg Bauhaus
2011-10-04 16:47                           ` Yannick Duchêne (Hibou57)
2011-10-04 15:41                     ` Yannick Duchêne (Hibou57)
2011-09-26 18:59       ` Jeffrey Carter
2011-09-27  0:35         ` Robert A Duff
2011-10-04  4:30         ` Yannick Duchêne (Hibou57)
2011-10-04 18:40           ` Jeffrey Carter
2011-09-26 14:29     ` Georg Bauhaus
2011-09-26 15:31       ` Georg Bauhaus
2011-10-04  4:35       ` Yannick Duchêne (Hibou57)
2011-10-04  4:13     ` Yannick Duchêne (Hibou57)
2011-09-25 17:16 ` Jeffrey Carter
2011-09-25 21:53   ` Robert A Duff
2011-09-26  9:25     ` Georg Bauhaus [this message]
2011-09-26 23:00     ` Randy Brukardt
2011-09-27  0:34       ` Robert A Duff
replies disabled

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