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: 103376,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!fdn.fr!news.wanadoo.fr!news.wanadoo.fr!not-for-mail Message-ID: <482EF951.9010604@obry.net> Date: Sat, 17 May 2008 17:27:13 +0200 From: Pascal Obry Organization: Home - http://www.obry.net User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: comp.lang.ada To: Bob Klungle Subject: Re: memory management in Ada: tedious without GC? References: <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com> <482E8A9D.5040401@obry.net> <8ACXj.3769$IK5.622@trnddc04> In-Reply-To: <8ACXj.3769$IK5.622@trnddc04> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Date: 17 May 2008 17:27:17 CEST NNTP-Posting-Host: 90.22.117.59 X-Trace: 1211038037 news.orange.fr 875 90.22.117.59:2555 X-Complaints-To: abuse@orange.fr Xref: g2news1.google.com comp.lang.ada:160 Date: 2008-05-17T17:27:17+02:00 List-Id: Bob Klungle a �crit : > "Pascal Obry" wrote in message > news:482E8A9D.5040401@obry.net... >> jhc0033@gmail.com a �crit : >>> Did I misunderstand? >> You have already received a bunch of excellent answers. I'd like to point >> out that in Ada you have less need for dynamically allocated memory. Ada >> supports unconstraint types. Objects of such types when declared can be >> "allocated" on the stack and passed around (no heap usage). A simple >> example: >> >> type Vector is (Positive range <>) of Float; >> >> 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. >> >> Pascal. > > Actually, the same construct exists in c/c++. Ok, I meant a non statically known constraint. My example was not accurate enough then. type Vector is (Positive range <>) of Float; function Norm (V : in Vector) return Float; ... N := ; declare V : Vector (1 .. N); R : Float; begin R := Norm (V); ... > Stack frame allocation only needs a block to allow object definitions (c++ > does it almost anywhere). And for anything else when the size of the object is not known at compile time. That's why I talked specifically about unconstraint objects. Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.obry.net --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595