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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,73175d2d01a1b1dd X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.8.135 with SMTP id r7mr21536105pba.8.1317029149779; Mon, 26 Sep 2011 02:25:49 -0700 (PDT) Path: lh7ni5203pbb.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!newsfeed.utanet.at!newsfeed01.chello.at!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 26 Sep 2011 11:25:47 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: subprogram must not be deeper than access type References: In-Reply-To: Message-ID: <4e80451b$0$6550$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 26 Sep 2011 11:25:48 CEST NNTP-Posting-Host: 28f50568.newsspool4.arcor-online.net X-Trace: DXC=VWd7F]o3H\5]E=H1Q9`7874IUK:D09nc\616M64>:Lh>_cHTX3j=Z70VnJOQBN5 X-Complaints-To: usenet-abuse@arcor.de Xref: news1.google.com comp.lang.ada:18124 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-09-26T11:25:48+02:00 List-Id: 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;