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,38c827f7e800d317 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-27 10:16:59 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!lnsnews.lns.cornell.edu!newsstand.cit.cornell.edu!ngpeer.news.aol.com!newsfeed1!bredband!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!usenet-fr.net!enst.fr!not-for-mail From: "Andrew" Newsgroups: comp.lang.ada Subject: conversion Date: Fri, 27 Jun 2003 11:37:09 -0600 Organization: ENST, France Message-ID: NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1056734217 22822 137.194.161.2 (27 Jun 2003 17:16:57 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 27 Jun 2003 17:16:57 +0000 (UTC) To: Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.3718.0 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3718.0 X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:39834 Date: 2003-06-27T11:37:09-06:00 Ok, so I found the ada.strings.unbounded package spec and body and took a look at the definition and implementation of unbounded string. Finally I found them! Unbounded_string is basically an object that contains a reference to a string. It would be something like: typdef struct unbounded_string{ char* reference; } with methods to manipulate the structure. My example may not be syntactically correct but I think I convey the basic idea. String is an array, Unbounded_String is an "object" that contains a reference to an array. So...The conversion from Unbounded_String to String is pretty easy. Return the pointer de-reference. From String to Unbounded_String is the expensive one. In general it is: allocate memory copy values from old to new return the new. So, using unbounded and calling to_string is relatively fast. Good, I'm satisfied with that part. I think it would be easy enough to create a slice and trim method that returned an unbounded_string so that I would not have to use the expensive string to unbounded_string conversion and that nagging inconvenience would be pacified. Dmitry mentioned that get_line reads in to a string buffer. Then after the line was read another string could be made because the last parameter is the length of what was read. Your absolutely right! I knew that and looked right over it. It wasn't hard at all to write a program that uses to_string and to_unbounded_string. It works. It's just that I didn't realize in design that I would need so many conversions and I wasn't fluent enough with all the "utility" methods like slice, trim, head, etcetera to really specify at design time whether I needed String or Unbounded_String. Once implementation time came up I almost immediately had to go back to design because I was introducing so much code for the conversions. I thought "there has to be a better way". Something else I really like about Ada is separate compilation. I can separate subprocedures into other files with the "is separate" and Separate() feature. That one thing would make code SO much more manageable. I could spread that thing out and assign tasks by function if needed. Then, just compile! I also was trying to get gnatmem to run but it fails. Has anyone used the Ada Core Technologies compiler? How does it compare to the public GNAT that I'm using; comes with FreeBSD Unix. Thanks for the help! Andrew