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-Thread: 103376,640b65cbfbab7216 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Sat, 05 Apr 2008 13:36:42 +0200 From: Gautier User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada.Strings.Bounded References: <47F26C46.3010607@obry.net> <44d88b93-6a90-4c18-8785-2164934ba700@a9g2000prl.googlegroups.com> <47F652F7.9050502@obry.net> <47f7028d$1_6@news.bluewin.ch> <47F749CB.30806@obry.net> In-Reply-To: <47F749CB.30806@obry.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 83.77.148.15 X-Original-NNTP-Posting-Host: 83.77.148.15 Message-ID: <47f7644d_2@news.bluewin.ch> X-Trace: news.bluewin.ch 1207395405 83.77.148.15 (5 Apr 2008 13:36:45 +0200) Organization: Bluewin AG Complaints-To: abuse@bluewin.ch X-Original-NNTP-Posting-Host: 127.0.0.1 Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!164.128.36.58!news.ip-plus.net!newsfeed.ip-plus.net!news.bluewin.ch!not-for-mail Xref: g2news1.google.com comp.lang.ada:20836 Date: 2008-04-05T13:36:42+02:00 List-Id: Pascal Obry wrote: ... > With Unbounded_String we are close to something "usable". That's clear. I think Adam's question was really specific to the bounded strings. Unbounded_String is the most comfortable and the safest, but needs dynamic allocation behind the scenes, which can be a handicap on some special situations (performance-critical, systems without dynamic allocation,...). > U1 : Unbounded_String; > U2 : Unbounded_String; > > U1 := U2; > > Works fine! But then it becomes a bit messy when converting back and > forth with the string type. > > U1 := To_Unbounded_String ("whatever"); > > Put_Line (To_String (U1)); > > Not a big deal, but if we can find a nice way to tell that such routine > must be used for conversion between type it will be quite handy. > > type Unbounded_String is ...; > > function To_String (U : Unbounded_String) return String; > > for Unbounded_String'Conversion (String) use To_String; > > Just to get the idea, then one could write: > > Put_Line (U1); > > Of course this raises some questions: > > What to do if we have Put_Line defined for String and > Unbounded_String? Which version gets called? > > ... > > Anyway that's just some wild thoughts :) I agree with Dmitry that it would lead to confusing situations, something that Ada normally tries to avoid... What I'm doing to make life easier is to paste the following lines in my sources function S (Source : Ada.Strings.Unbounded.Unbounded_String) return String renames Ada.Strings.Unbounded.To_String; function U (Source : String) return Ada.Strings.Unbounded.Unbounded_String renames Ada.Strings.Unbounded.To_Unbounded_String; After the sources only need short S(...)'s and U(...)'s which are ok to me: external_packer: array(External) of Unbounded_String:= ( U("zip.exe"), U("7z.exe"), U("kzip.exe") ); ... return "External: " & S(external_title(a)) & ", " & S(external_options(a)); ... e.name:= U(unique_name); ..., etc. etc. ______________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/index.htm Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!