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-Thread: a07f3367d7,4cad17e8664256c9 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes 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.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 28 May 2009 15:00:12 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Allocation questions References: <4a1e5d9e$0$2868$ba620e4c@news.skynet.be> <96a89bf4-4968-45fb-aa5b-4a47f2e06045@f19g2000yqo.googlegroups.com> In-Reply-To: <96a89bf4-4968-45fb-aa5b-4a47f2e06045@f19g2000yqo.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4a1e8add$0$30233$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 28 May 2009 15:00:13 CEST NNTP-Posting-Host: b59cf41c.newsspool1.arcor-online.net X-Trace: DXC=M0B`iE673LCAa;:RKVJ>LEic==]BZ:afN4Fo<]lROoRA^YC2XCjHcbI>Bg_PWGoIhC;9OJDO8_SKFNSZ1n^B98iJoA2Jm8o`E9K X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6070 Date: 2009-05-28T15:00:13+02:00 List-Id: Ludovic Brenta schrieb: > xavier grave: >>> Or you could use a discriminant: >>> type Samples (No_Of_Samples : Natural := 0) is >>> record >>> S : array (1 .. No_Of_Samples) of Sample; >>> end record; >> My two cents about variant discriminant : IMHO one should avoid to >> declare No_Of_Samples as Natural and with a default value, because as >> far as I remember some compilers will book for S (1 .. Natural'Last) of >> Sample which can be a lot... >> >> May be some compiler guru can confirm or infirm this ? > > I confirm this with GNAT even though I'm no guru. Well spotted, > Xavier. Using GNAT and -fstack-check, this will stem towards the stack limit (Dummy just declares Samples records of increasing No_Of_Samples): with Ada.Text_IO; procedure GNAT_Varrec is type Sample is new Float range 0.0 .. 1.0; type Run is array (Natural range <>) of Sample; type Samples (No_Of_Samples : Natural := 0) is record S : Run (1 .. No_Of_Samples); end record; procedure Dummy (N: Natural) is Scratch: Samples(No_Of_Samples => N); begin if N in Scratch.S'Range then Scratch.S(N) := 0.5; end if; end Dummy; K : Natural; package Text_IO renames Ada.Text_IO; begin K := 0; while K < Natural'Last loop Text_IO.Put_Line("Size is " & Natural'Image(K * Sample'Size / 8) & " octets"); Text_IO.Flush; Dummy(K); K := K + 4096; end loop; end GNAT_Varrec;