comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex R. Mosteo" <alejandro@mosteo.com>
Subject: Re: Newbie question -- dereferencing access
Date: Mon, 16 Mar 2009 09:30:56 +0100
Date: 2009-03-16T09:30:56+01:00	[thread overview]
Message-ID: <726h2hFo6mthU1@mid.individual.net> (raw)
In-Reply-To: 49BA8A57.7090200@tgrowe.plus.net

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.




  parent reply	other threads:[~2009-03-16  8:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11 20:26 Newbie question -- dereferencing access Tim Rowe
2009-03-11 20:46 ` Ludovic Brenta
2009-03-12  9:57   ` Tim Rowe
2009-03-12 10:16     ` Ludovic Brenta
2009-03-12 13:24       ` Tim Rowe
2009-03-12 12:13     ` christoph.grein
2009-03-12 13:00       ` Tim Rowe
2009-03-12 13:30       ` Ed Falis
2009-03-13  9:55         ` Tim Rowe
2009-03-13 11:06           ` Alex R. Mosteo
2009-03-13 16:31             ` Tim Rowe
2009-03-13 16:52               ` Georg Bauhaus
2009-03-13 17:31                 ` Tim Rowe
2009-03-13 18:18                   ` Tim Rowe
2009-03-13 18:27                     ` Pascal Obry
2009-03-13 18:46                     ` Niklas Holsti
2009-03-13 21:38                       ` Tim Rowe
2009-03-13 22:28                         ` Per Sandberg
2009-03-13 16:52               ` Tim Rowe
2009-03-13 17:33               ` Martin
2009-03-14  7:30                 ` sjw
2009-03-14  7:45                   ` sjw
2009-03-14  9:21                   ` Martin
2009-03-23  8:43                     ` Martin
2009-03-16  8:30               ` Alex R. Mosteo [this message]
2009-03-13 16:50             ` Tim Rowe
2009-03-13 16:19           ` Martin
2009-03-12 16:43     ` qunying
2009-03-12 18:21     ` Ivan Levashew
2009-03-13  5:59       ` christoph.grein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox