comp.lang.ada
 help / color / mirror / Atom feed
From: "Andrew Carroll" <andrew@carroll-tech.net>
To: <comp.lang.ada@ada-france.org>
Subject: Modes (was unbounded_string)
Date: Fri, 10 Oct 2003 02:27:19 -0600
Date: 2003-10-10T02:27:19-06:00	[thread overview]
Message-ID: <mailman.60.1065773352.25614.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: 20031010074015.761204C40C1@lovelace.ada-france.org

>>For all other types, the compiler chooses the parameter 
>>mode best suited to the type. 
Great!!!  SIGN ME UP!!!  But...is it possible that the compiler 
doesn't get it right?  What would I need to do if I found that
the compiler didn't get it right in my testing?  I'm guessing
that you will say, "specify the mode".

package x is
type x;
type xptr is access x;
type x is tagged limited record
 head: nodeptr; 
 something: unbounded_string;
end record;

--creates a new node to put into the 'head' list.
--new node is created from information in token.
--token has nothing to do with the 'something' variable
--declared in the record above.
procedure add(this: xptr; token: unbounded_string); 

end x;

So, with the above code "example", xptr is passed as an 'in'
or 'in out' mode at the add procedure?  

Are you saying that I should use just x and not xptr as the
parameter so that the compiler will choose the correct mode?
If so, you recommend it because of deallocation issues?


On to strings...
>> 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.
[snip]
>> The "Ada Way" / "Ada idiom"

Is there something in the code below that I missed about information 
hiding?  

Temp: gnat.os_lib.String_Access;
...
Temp := gnat.os_lib.getenv("QUERY_STRING");
...
---------------------------------------
-- ready to use Temp for something else
---------------------------------------
Temp := gnat.os_lib.getenv("SOME_OTHER_VARIABLE");

Considering the code above, what is the "Ada idiom" to "resize" a String
without pointers and dynamic allocation?  In other words; what "Ada 
idiom" code would you write to do the same thing I did, without pointers
and dynamic allocation?  You don't have to write the code, a good 
reading reference would be okay.

Thanks!
















       reply	other threads:[~2003-10-10  8:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20031010074015.761204C40C1@lovelace.ada-france.org>
2003-10-10  8:27 ` Andrew Carroll [this message]
2003-10-10  9:15   ` Modes (was unbounded_string) Dmitry A. Kazakov
2003-10-11  7:16     ` Simon Wright
2003-10-13  9:28       ` Dmitry A. Kazakov
2003-10-10 15:18   ` Stephen Leake
2003-10-10 16:21     ` Martin Dowie
2003-10-14 18:47     ` Craig Carey
2003-10-10 19:06   ` Jeffrey Carter
2003-10-13  9:33     ` Dmitry A. Kazakov
2003-10-13  9:40       ` Stephane Richard
2003-10-13 10:12         ` Dmitry A. Kazakov
2003-10-15  2:16         ` Warren W. Gay VE3WWG
2003-10-15  3:36           ` Jeff C,
2003-10-16 16:45             ` Warren W. Gay VE3WWG
     [not found] <20031010094017.680474C40C1@lovelace.ada-france.org>
2003-10-10 10:58 ` Andrew Carroll
replies disabled

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