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!


|