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 Path: g2news2.google.com!postnews.google.com!b7g2000pre.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Allocation questions Date: Thu, 28 May 2009 07:51:50 -0700 (PDT) Organization: http://groups.google.com Message-ID: <336b285f-2245-4ede-8528-841a2c713e80@b7g2000pre.googlegroups.com> 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> <78f30732-8d8d-4009-b9ed-ba19d275a5d9@f16g2000vbf.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1243522310 4038 127.0.0.1 (28 May 2009 14:51:50 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 28 May 2009 14:51:50 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b7g2000pre.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6074 Date: 2009-05-28T07:51:50-07:00 List-Id: On May 28, 6:39=A0am, Martin wrote: > > 2 more questions: > > > 1) In fact (due to my background!), I would like to use the dot notatio= n: > > object.method. > > So I have add "tagged": I'm not sure I'd recommend declaring a type "tagged" JUST to get the dot notation. There's a small amount of overhead involved with making a type tagged; but more importantly, a fair number of language rules are different for tagged types than for untagged types. (You ran into one different rule below; another one that comes to mind immediately is that there are differences in the semantics of "=3D". There are others. You might not run into any of them, though.) > > =A0 =A0 =A0type Delay_Type (Size : Nb_Of_Samples :=3D 0) is tagged priv= ate; > > =A0 =A0 =A0... > > private > > =A0 =A0 =A0type Delay_Type (Size : Nb_Of_Samples :=3D0) is tagged recor= d > > =A0 =A0 =A0 ... > > > When I compile, I have: > > "discriminants of tagged type cannot have defaults" > > How can I fix it ? > > Just remove the " :=3D 0" bit. To elaborate, the main advantage of using the default is that after you declare an object of type Delay_Type, you can change its Size by reassigning the whole object. If you don't need to use this feature--- i.e. if you will declare an object of type Delay_Type(Size=3D>N) and then never change the Size of that object afterwards---then I don't think there's any need to use the default. > > 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 ? As Xavier pointed out, using a default could cause a lot larger array to be allocated (because the Size could be changed later). If you remove the default, this problem may go away on its own. I don't see how an array of five million floats would cause a problem. (Not these days, anyway. Back when I used to work on a mainframe that took up a whole room and had a whopping ONE MEGABYTE of RAM, maybe it would have been a problem. I also used to put my COBOL programs on punch cards and walk five miles to school, uphill both ways...) -- Adam