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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!novso.com!news.skynet.be!195.238.0.222.MISMATCH!newsspl501.isp.belgacom.be!tjb!not-for-mail Date: Thu, 28 May 2009 14:32:01 +0200 From: Olivier Scalbert User-Agent: Thunderbird 2.0.0.21 (X11/20090409) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Allocation questions References: <4a1e5d9e$0$2868$ba620e4c@news.skynet.be> <106ssailgl19b$.1sngvazrm7u5w.dlg@40tude.net> <40a2a911-6b92-407e-b1e3-deabf154892f@x6g2000vbg.googlegroups.com> In-Reply-To: <40a2a911-6b92-407e-b1e3-deabf154892f@x6g2000vbg.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4a1e8454$0$2861$ba620e4c@news.skynet.be> Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: ba041bc5.news.skynet.be X-Trace: 1243513940 news.skynet.be 2861 87.65.198.18:52437 X-Complaints-To: usenet-abuse@skynet.be Xref: g2news2.google.com comp.lang.ada:6068 Date: 2009-05-28T14:32:01+02:00 List-Id: Martin wrote: > On May 28, 11:05 am, "Dmitry A. Kazakov" > > p.s. here's a demo: > > with Ada.Text_IO; use Ada.Text_IO; > procedure Demo is > package D is > type No_Of_Samples is range 0 .. 1_000; > type A_of_F is array (No_Of_Samples range <>) of Float; > type R (S : No_Of_Samples := 0) is private; > function Create (N : No_Of_Samples) return R; > procedure Put_Line (This_R : R); > private > type R (S : No_Of_Samples := 0) is > record > I : Integer; > B : Boolean; > A : A_Of_F (1 .. S); > end record; > end D; > package body D is > function Create (N : No_Of_Samples) return R is > begin > return (S => N, > I => 0, > B => False, > A => (others => 0.0)); > end Create; > procedure Put_Line (This_R : R) is > begin > Put_Line (Integer'Image (This_R.I)); > Put_Line (Boolean'Image (This_R.B)); > Put_Line (No_Of_Samples'Image (This_R.S)); > for I in This_R.A'Range loop > Put_Line (Float'Image (This_R.A (I))); > end loop; > end Put_Line; > end D; > > R_1 : D.R := D.Create (1); > R_5 : D.R := D.Create (5); > begin > D.Put_Line (R_1); > D.Put_Line (R_5); > end Demo; Thanks Martin, it works! 2 more questions: 1) In fact (due to my background!), I would like to use the dot notation: object.method. So I have add "tagged": type Delay_Type (Size : Nb_Of_Samples := 0) is tagged private; ... private type Delay_Type (Size : Nb_Of_Samples :=0) is tagged record ... When I compile, I have: "discriminants of tagged type cannot have defaults" How can I fix it ? 2) If Nb_Of_Samples range is too large, around 1..5_000_000, I have a nice Segmentation fault. How can I fix that ? Thanks Olivier