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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,13b19740d69cbdc2,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-10 01:10:42 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: "Andrew Carroll" Newsgroups: comp.lang.ada Subject: Modes (was unbounded_string) Date: Fri, 10 Oct 2003 02:27:19 -0600 Organization: Cuivre, Argent, Or Message-ID: References: <20031010074015.761204C40C1@lovelace.ada-france.org> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1065773353 60183 80.67.180.195 (10 Oct 2003 08:09:13 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Fri, 10 Oct 2003 08:09:13 +0000 (UTC) To: Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Gateway to the comp.lang.ada Usenet newsgroup List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:587 Date: 2003-10-10T02:27:19-06:00 >>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!