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-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.straub-nv.de!noris.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Allocation questions 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: <4a1e5d9e$0$2868$ba620e4c@news.skynet.be> <106ssailgl19b$.1sngvazrm7u5w.dlg@40tude.net> <40a2a911-6b92-407e-b1e3-deabf154892f@x6g2000vbg.googlegroups.com> <4a1e8454$0$2861$ba620e4c@news.skynet.be> Date: Thu, 28 May 2009 16:04:56 +0200 Message-ID: <70ficak1w3p6$.1ueywlpft3yum.dlg@40tude.net> NNTP-Posting-Date: 28 May 2009 16:04:56 CEST NNTP-Posting-Host: 5873f787.newsspool2.arcor-online.net X-Trace: DXC=UH\CUZo1QA5gP]QSEBQ^d4A9EHlD;3Yc24Fo<]lROoR1^YC2XCjHcb94?@:MRG^:N1DNcfSJ;bb[5FCTGGVUmh?4LK[5LiR>kg2k]19iL0L5b0 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6073 Date: 2009-05-28T16:04:56+02:00 List-Id: On Thu, 28 May 2009 14:32:01 +0200, Olivier Scalbert wrote: > 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 ? That depends. The default values are used in order to fix the object size (to maximum possible). That is not your case. Since you have Create_Delay that returns Delay_T, you can do: type Delay_Type (<>) is tagged private; function Create_Delay (Time_Value: Time) return Delay_T; private type Delay_Type (Size : Nb_Of_Samples) is tagged record > 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 ? You should increase the stack (allocated per task). Since Delay_Type is potentially huge, I suggest to make it limited in order to prevent accidental copying: type Delay_T (<>) is tagged limited private; function Create_Delay (Time_Value: Time) return Delay_T; private type Delay_T (Size : Natural) is tagged limited record Delay_Time: Time; Output : Sample; Samples : Samples_Array (1..Size); end record; The "function" Create_Delay will look like (Ada 2005): function Create_Delay (Time_Value: Time) return Delay_T is begin return Result : Delay_T (Natural (Time_Value * 44_100.0)) do Result.Delay_Time := Time_Value; Result.Output := 0.0; end return; end Create_Delay; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de