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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,67fd28f4008484be X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: unconstrained subtype in component declaration, tagged OO Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Sat, 26 Mar 2011 21:42:16 +0100 Message-ID: <1v6bdfssnx5jd$.1k5a6782kgvu5.dlg@40tude.net> NNTP-Posting-Date: 26 Mar 2011 21:42:14 CET NNTP-Posting-Host: a7c8de1a.newsspool2.arcor-online.net X-Trace: DXC=ANRMUIjEIBRAX0F2i>oc\h660kVX X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:19450 Date: 2011-03-26T21:42:14+01:00 List-Id: On Sat, 26 Mar 2011 13:24:37 -0700, Nasser M. Abbasi wrote: > I am learning a bit about Ada OO, and I have simple problem, > hopefully with simple answer, but not able to find one so far. > > I want to make an object, but the declaration of the tagged record > would include an array in it. The size of this array, at the > time of declaration is not know. But will be when the > object is created. > > So, what is the correct way to declare such an object? > > Here is my ads package for the object: > > -------------------foo.ads------- > package foo is > type foo_t is tagged private; type foo_t (<>) is tagged private; > -- primitive operations > function make(n:natural) return foo_t; > private > type u_t is array(natural range<>) of float; > > type foo_t is tagged record > u : u_t:= (others=>0.0); -- problem here > end record; type foo_t (Length : Natural) is tagged record u : u_t (1..Length) := (others=>0.0); end record; function make(n:natural) return foo_t is begin return (n, (others => 0.0)); end make; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de