comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: Unbounded Strings
Date: Wed, 08 Oct 2003 18:46:18 GMT
Date: 2003-10-08T18:46:18+00:00	[thread overview]
Message-ID: <_XYgb.3237$dn6.2766@newsread4.news.pas.earthlink.net> (raw)
In-Reply-To: <mailman.47.1065591264.25614.comp.lang.ada@ada-france.org>

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.

Basically, you have reinvented the wheel. What you have is 
Unbounded_String, but with its guts hanging out all over the place, 
instead of using information hiding as a software engineer should, and 
as Ada.Strings.Unbounded does.

> I found myself desingning more and debugging less.  There were still
> problems
> of course, such as pass by value or pass by reference; I didn't know what to
> use
> nor did I know if I had to specify it.  I found out when I created my first
> graph,
> you have to specify out paramter or in and out for the parameter or you get
> a
> copy instead of the actual "thing".

This represents a serious misunderstanding of Ada parameter modes. All 
elementary types are passed by copy, regardless of the parameter mode. 
All tagged and limited types are passed by reference, regardless of the 
parameter mode. For all other types, the compiler chooses the parameter 
mode best suited to the type. Mode in means the subprogram receives a 
value from the caller, and cannot modify it; out means the subprogram 
provides a value to the caller, and in out means the caller provides a 
value which the subprogram may modify. Parameter modes have nothing to 
do with parameter passing mechanisms. See ARM 6.2.

-- 
Jeff Carter
"I blow my nose on you."
Monty Python & the Holy Grail
03




  parent reply	other threads:[~2003-10-08 18:46 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
2003-10-08 13:19     ` Steve O'Neill
2003-10-08 18:46   ` Jeffrey Carter [this message]
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