comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <nobody@noplace.com>
Subject: Re: Unbounded Strings
Date: Wed, 08 Oct 2003 13:10:23 GMT
Date: 2003-10-08T13:10:23+00:00	[thread overview]
Message-ID: <3F840CBE.6080904@noplace.com> (raw)
In-Reply-To: mailman.47.1065591264.25614.comp.lang.ada@ada-france.org

Pointers to strings are certainly possible in Ada, but that's kind of a 
sign of a C/C++ programmer trying to utilize all their C/C++ idioms in a 
different language. I remember quite a while back watching a C guy 
struggling with Ada and trying to use 'Address everywhere in passing 
parameters like strings to subroutines. He was convinced he needed to do 
that to get a "by reference" parameter because he was so conditioned to 
think that way by C. Obviously, you *can* do it that way - its just not 
necessary and really makes your life harder.

If you learn to utilize Ada's features with "Ada Idioms", you really 
don't need the pointers and dynamic allocation - at least not for normal 
string manipulation. You always *can* do it, but you don't have to do 
it. That tends to reduce the risks of dangling pointers and memory 
leaks, so you might want to try to learn "The Ada Way". :-)

MDC


Andrew Carroll wrote:
> 
> I did some experimenting, thanks to Cohen's book and persistance I found
> that I can define a pointer to a string type in Ada and allocate a new
> string when
> I want one of a different size, sort of like char* in C/C++, with the
> benefits of
> Ada bounds checking (if that still exist by default) and the memory
> management I briefly scanned over in the last comp.lang.ada email.
> 


-- 
======================================================================
Marin David Condic
I work for: http://www.belcan.com/
My project is: http://www.jsf.mil/NSFrames.htm

Send Replies To: m c o n d i c @ a c m . o r g

     "All reformers, however strict their social conscience,
      live in houses just as big as they can pay for."

          --Logan Pearsall Smith
======================================================================




  parent reply	other threads:[~2003-10-08 13:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20031007175516.DC2884C40C8@lovelace.ada-france.org>
2003-10-08  5:52 ` Unbounded Strings Andrew Carroll
2003-10-08  6:22   ` Preben Randhol
2003-10-08 13:10   ` Marin David Condic [this message]
2003-10-08 13:19     ` Steve O'Neill
2003-10-08 18:46   ` Jeffrey Carter
2003-10-08 23:55     ` Mark Lorenzen
2003-10-09 18:23     ` Craig Carey
replies disabled

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