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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b672743914db49f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!50g2000hsm.googlegroups.com!not-for-mail From: Tomek Wa kuski Newsgroups: comp.lang.ada Subject: Re: "Ada Gems": Constructor functions Date: Thu, 06 Sep 2007 07:54:02 -0000 Organization: http://groups.google.com Message-ID: <1189065242.201148.254440@50g2000hsm.googlegroups.com> References: <1189015827.384331.17490@k79g2000hse.googlegroups.com> <1189064716.528979.201170@19g2000hsx.googlegroups.com> NNTP-Posting-Host: 83.26.83.73 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1189065242 17221 127.0.0.1 (6 Sep 2007 07:54:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 6 Sep 2007 07:54:02 +0000 (UTC) In-Reply-To: <1189064716.528979.201170@19g2000hsx.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.1.6) Gecko/20070801 Firefox/2.0.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: 50g2000hsm.googlegroups.com; posting-host=83.26.83.73; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1777 Date: 2007-09-06T07:54:02+00:00 List-Id: The "working" code is: t.ads: with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package T is type Object (<>) is tagged limited private; function Create_Object (Name : in String) return Object; function Construct return Object; function Name (This : in Object) return String; private type Object is tagged limited record Name : Unbounded_String; end record; end T; t.adb: package body T is function Create_Object (Name : in String) return Object is begin return (Name => To_Unbounded_String (Name)); end Create_Object; function Construct return Object is begin return Create_Object (Name => "Object without a name!"); end Construct; function Name (This : in Object) return String is begin return To_String (This.Name); end Name; end T; test_t.adb: with T; procedure Test_T is Some_Object : constant T.Object := Construct; begin null; end Test_T; ------ tomek@genbox [~/Desktop/test_t] $ gnatmake test_t.adb gnatgcc -c test_t.adb test_t.adb:4:39: "Construct" is not visible test_t.adb:4:39: non-visible declaration at t.ads:8 gnatmake: "test_t.adb" compilation error (and no bug report) Why "Construct" is not visible?