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,c0d4e990924eb044 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Newbie question -- dereferencing access Followup-To: comp.lang.ada Date: Mon, 16 Mar 2009 09:30:56 +0100 Message-ID: <726h2hFo6mthU1@mid.individual.net> References: <72516b38-1711-4588-b53b-7b42773f70c2@w34g2000yqm.googlegroups.com> <1IednThMP8E8sCfUnZ2dnUVZ8suWnZ2d@posted.plusnet> <71ut2oFn4m2pU1@mid.individual.net> <49BA8A57.7090200@tgrowe.plus.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Trace: individual.net 1fsje06nD3GgqI9WkQFQewiRZX2jiB0fUzDjnNYYNXlmMdHmg= Cancel-Lock: sha1:Cq6KuJWCtXTRJpMZZ6xNR7JXunQ= User-Agent: KNode/0.99.01 Xref: g2news2.google.com comp.lang.ada:5108 Date: 2009-03-16T09:30:56+01:00 List-Id: Tim Rowe wrote: > Alex R. Mosteo wrote: > >> While these are certainly important skills, one thing you should notice >> when transitioning to Ada is a decreased need for access types thanks to >> unconstrained/indefinite types. I'd think that would mean that you're in >> the right track. > > But I can't put an unconstrained type into a record. I realise that I > can make the record discriminated and constrain the type on the > discriminant, trying to write a class that gives strtok-like > functionality -- the excercise I have set myself at the moment -- means > that I discover the sizes of relevant strings rather late in the game. I was only slightly concerned by your initial example of access String, which are very rarely needed. It is unfortunate that they tend to appear in examples of arrays of strings of different length, though, in not very advanced tutorials. I think you've already discovered the predefined string packages. >> Anyway, if you have a sound knowledge of memory management in C/C++, it's >> pretty much the same. Don't forget to deallocate, wrap it all in a >> controlled type. > > What I'm feeling the lack of is destructors for classes (sorry, for > tagged records). I suspect I'll find what I need when I learn about > finalizers, but whereas in C++ I learned about delete at the same time > as I learned about new, and I learned about destructors at the same time > as I learned about constructors, it seems strange in Ada to find access > allocation addressed in the mainstream and access deallocation relegated > to an advanced topic (and destructors nowhere in my sight). And yet it's > C/C++ that has the reputation for memory leaks! It may be a bit puzzling in the very beginning, when you don't yet have all the pieces, but really all these topics tend to appear fairly soon. I don't remember that Unchecked_Deallocation received a comparably smaller attention than "new" in my formation. However, with the need for instantiation and the strange long name, it was stressed that the need for access types should be carefully studied. Finalization OTOH tends to be thrown in the lot of object oriented programming, which may be the reason you haven't seen it yet. However, Finalization is by no means an advanced topic and you'll find it very soon, I'd expect.