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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,adae40bcc4d01baf,start X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!i3g2000hsf.googlegroups.com!not-for-mail From: shaunpatterson@gmail.com Newsgroups: comp.lang.ada Subject: Ada 95 constructors on limited types Date: Wed, 2 Jan 2008 06:31:39 -0800 (PST) Organization: http://groups.google.com Message-ID: <08dc2b30-6c8c-4cff-9f2e-c0d4c377972d@i3g2000hsf.googlegroups.com> NNTP-Posting-Host: 155.219.241.10 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1199284299 26765 127.0.0.1 (2 Jan 2008 14:31:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 2 Jan 2008 14:31:39 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i3g2000hsf.googlegroups.com; posting-host=155.219.241.10; posting-account=O0hwoQoAAABTUhctVKyLpysYxVt3QnYo User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; .NET CLR 3.0.04506.648),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19144 Date: 2008-01-02T06:31:39-08:00 List-Id: I am trying to write a constructor that will return an access type to a new object. What I what is something like: procedure Test is Test_Pointer : Parent.Class_Access := new Parent.Child.Create (5); begin null; end Test; Parent.ads: package Parent is type Class is abstract tagged limited null record; type Class_Access is access all Class'Class; end Parent; package Parent.Child is type Class is new Parent.Class with private; function Create (Test_Value : Integer) return Class_Access; -- function Create (Test_Value : Integer) return Class; private type Class is new Parent.Class with record Value : Integer := 0; end record; end Parent.Child; package body Parent.Child is function Create (Test_Value : Integer) return Class_Access is begin return new Class' (Value => Test_Value); -- Works only with Ada 2005... I am stuck using Ada 95 end Create; -- function Create (Test_Value : Integer) return Class is -- begin -- return Class' (Value => Test_Value); -- end Create; end Parent.Child; So, the first create works in Ada2005 with: Test_Pointer : Parent.Class_Access := Parent.Child.Create (5); I have also tried the second Create unsuccessfully with Test_Pointer : Parent.Class_Access := new Parent.Child.Create (5); I don't understand how to initialize limited types and their pointers. Any help? Again, my project currently is tied down to Ada95 (gnat 3.16p) -- Shaun