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-Thread: 103376,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.karotte.org!news.musoftware.de!wum.musoftware.de!feeder.erje.net!newsfeed-fusi2.netcologne.de!news.netcologne.de!newsfeed-hp2.netcologne.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 17 May 2008 18:18:32 +0200 From: Georg Bauhaus Reply-To: rm.tsho+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.14 (X11/20080502) MIME-Version: 1.0 Newsgroups: comp.lang.ada 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> <482EF951.9010604@obry.net> In-Reply-To: <482EF951.9010604@obry.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <482f0558$0$6518$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 17 May 2008 18:18:32 CEST NNTP-Posting-Host: 41e22630.newsspool4.arcor-online.net X-Trace: DXC=>C3oKA1VHZ3RLigj];iP=84IUKejV8Lg5Ug[ai948lB=geBTVCj9 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:161 Date: 2008-05-17T18:18:32+02:00 List-Id: Pascal Obry wrote: > Bob Klungle a �crit : >> 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); > ... This won't convince a C++ programmer because they have typed template Lisp, checked element access, container properties, and stack allocated aggregates. What C++ does not have is full nesting, including access to auto variables of surrounding scopes and to function parameters. (This can be of use as demonstrated by Integrate and Iterate.) You can have local classes in C++ and even mimic local subprograms but this is clumsy. Ada nesting entails very straight forward lifetime control, much underused IMHO. (Plus GNAT performance is not as good as when everything is at library level.) Using scopes, you can control static and dynamic lifetimes types and objects (including tasks!). But somehow I think people are obsessed with making each and every type fully general and usable at library level (and in theory books and papers?), simply dismissing possibilities that declarative regions offer naturally. Is this a consequence of teaching and hyping mostly flat languages?