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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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:40:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: conversion Date: 27 Jun 2003 13:32:14 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1056735163 28194 128.183.235.92 (27 Jun 2003 17:32:43 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 27 Jun 2003 17:32:43 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: archiver1.google.com comp.lang.ada:39838 Date: 2003-06-27T17:32:43+00:00 List-Id: "Andrew" writes: > 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! ok. > > So...The conversion from Unbounded_String to String is pretty easy. > Return the pointer de-reference. Yes. > From String to Unbounded_String is the expensive one. In general it > is: allocate memory copy values from old to new return the new. Yes. > So, using unbounded and calling to_string is relatively fast. Good, > I'm satisfied with that part. Ok. > 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. What is your application? There are many other ways to represent pieces of strings. For example, you can store a string and a bunch of indexes into the string. > It wasn't hard at all to write a program that uses to_string and > to_unbounded_string. It works. Good. > 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. Yes, this is often the case when learning new utilities. My rule is that the design isn't right until you've redone it three times. > I thought "there has to be a better way". You'll get there :). > 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! Better to use child packages. "is separate" is really an Ada 83 feature; child packages in Ada 95 is a better way to structure things. Sometimes "is separate" is a good way to go, but rarely. > I also was trying to get gnatmem to run but it fails. Give an example of the code and error message; maybe I can help. > Has anyone used the Ada Core Technologies compiler? Yes. > How does it compare to the public GNAT that I'm using; comes with > FreeBSD Unix. Hmm, this is confused. GNAT _is_ the Ada Core Technologies (ACT) compiler. ACT is constantly developing the compiler; when they get a reasonably stable new version, they release it to their supported customers. After the supported customers have time to find some more bugs, they release it to the public. Then there is the version of GNAT bundled with the GCC release. ACT calls that 5.01w; gcc calls it 3.1. It is _not_ as well tested as the public ACT release. So as a supported customer, I'm using GNAT 3.16a. The one that comes with FreeBSD Unix may be 3.15p, or 3.1. Yes, it is confusing. But they are all versions of the same compiler. -- -- Stephe