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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!z72g2000hsb.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: memory management in Ada: tedious without GC? Date: Sat, 17 May 2008 09:51:21 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8640a12f-da99-435f-8eb6-372e175cd5b9@z72g2000hsb.googlegroups.com> References: <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com> <482E8A9D.5040401@obry.net> NNTP-Posting-Host: 85.3.228.71 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1211043082 1250 127.0.0.1 (17 May 2008 16:51:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 17 May 2008 16:51:22 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z72g2000hsb.googlegroups.com; posting-host=85.3.228.71; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:166 Date: 2008-05-17T09:51:21-07:00 List-Id: On 17 Maj, 09:34, Pascal Obry wrote: > function Norm (V : in Vector) return Float; > > ... > > declare > V : Vector (1 .. 100); > R : Float; > begin > R := Norm (V); > ... > > Not a single memory allocation. In C/C++ you'll need to dynamically > allocate V on the heap, and then worry about freeing this memory. Sorry for being a bit rude, but OP explicitly said that this is not for those who use the names C and C++ interchangeably. :-) The C++ programmer would do this: float norm(const vector & v); // and then: vector v(100); // ... float r = norm(v); No explicit allocation on the heap and no worry about deallocation. It is all automatic. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com