comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: conversion
Date: Wed, 09 Jul 2003 17:04:53 GMT
Date: 2003-07-09T17:04:53+00:00	[thread overview]
Message-ID: <3F0C4B18.6080204@attbi.com> (raw)
In-Reply-To: d2gngvk9li9mm0o563b5o6lhrqgb1vccur@4ax.com

Dmitry A. Kazakov wrote:

> This is what I meant. You can consider string literals as being of
> some unversal string type. Then you can have some parent string type
> for all string types. Call it root string if you want. The hierarchy
> might look like...

This is where your confusion starts.  String is the root type for all 
strings of Latin1 characters.  If you want a universal type what it 
needs to cover are things like Wide_String, Wide_Wide_String, and any 
user defined string types with either a different set of characters, or 
different index types.  Strings in Ada are much richer than your 
imagination realizes:

type Color is (Red, Orange, Yellow, Green, Blue, Violet);

type Digit is ('0','1','2','3','4','5','6','7','8','9');

type Digit_String is array (Color range <>) of Digit; -- new string type

Foo: Digit_String := "12345";

>>The Integer type that corresponds most closely to String, is Integer, 
>>and they are both declared in Standard.

> It does not. Because Integer is constrained.

And String is constrained in exactly the same way.  Most Ada 
implementations now have Integer'Last = 2**32-1, which not 
coincidentally is the maximum number of Characters in a String.

> You missed the point. String as a concept has a semantics which allows
> *any* values. That String as a type implementing  the concept has
> values constrained in some special way, does not change that
> semantics.

Hoo boy, you still are wearing blinders.  In concept a string could be 
any ordered set of say Japanese Kanji, or if you prefer, and the 
Japanese do, a mixture of Katakana, Hirigana, and Kanji.  In Ada this 
does't fit in a String, but Japanese is a subset of Wide_Character. And 
  so Wide_String is fine for Japanese. On the other hand, Wide_Character 
cannot represent all of the Chinese characters, there are already 
several additional planes of additional Chinese characters defined in 
ISO 10646.  In Ada the corresponding string type, if supported, would be 
Wide_Wide_Character.

> The problem is. Should String and Unbounded_String be siblings
> (descendants of same base), or better, as many would rightfully
> expect, String be *both* a subtype and a supertype of
> Unbounded_String, then we will have a lot of problems to solve.
> Because ADT in Ada is presently unable to deal with that.

But Unbounded_String is really a (very useful) container type for 
Standard.String, no more, no less.  I can easily imagine--because I have 
had to do it in Ada 83 which was not as friendly in this area--writing a 
package which had to display messages in Latin (English), Cyrillic, and 
Arabic.  Three separate (7-bit) character sets, and the corresponding 
string types.  If I were to rewrite that code in Ada 95, I would 
probably use the corresponding ISO 8859 8-bit character sets.  But I 
would need an instance of Ada.Strings.Bounded_String for each.  (Well 
actually only the Latin1 version could be an instance of 
Ada.Strings.Bounded_String, but that is a detail.)

Why am I spending so much time on this?  Simple.  A lot of effort over 
the years has gone into the support for additional character sets (and 
string types) in Ada.  The most recent discussion was whether or not to 
"officially" change the default character set to one of the new 8859 
variants with the Euro symbol.  (Verdict, no.)  People who look at Ada 
through a mono-linguistic filter tend to miss this.  But what really 
suprises me is the fact that many people whose first language is not 
English still tend to think of Ada as having an English bias. 
(Technically, Ada does have a slight Western European bias, but very 
slight, see 3.5.2.(4). And as I indicated above Ada does not define the 
Wide_Wide_Character type needed for full Chinese language support.)

-- 

                                                        Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are 
insignificant beside two prime questions, which are: 1. Can he shoot? 2. 
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and 
Steve Miller.




  reply	other threads:[~2003-07-09 17:04 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-27 10:51 conversion Andrew
2003-06-27 12:22 ` conversion Dmitry A. Kazakov
2003-06-27 12:37 ` conversion Stephen Leake
2003-06-27 14:26   ` conversion Bill Findlay
2003-06-27 17:04     ` conversion Georg Bauhaus
2003-07-04  0:21     ` conversion Dave Thompson
2003-06-27 13:25 ` conversion Robert I. Eachus
2003-06-27 18:42   ` conversion tmoran
2003-06-27 14:49 ` conversion Matthew Heaney
2003-06-27 17:10 ` conversion Georg Bauhaus
2003-06-27 17:13 ` conversion Alexander Kopilovitch
2003-06-27 17:34   ` conversion Preben Randhol
2003-06-27 22:10     ` conversion Alexander Kopilovitch
2003-06-28  9:46       ` conversion Preben Randhol
2003-06-27 22:13   ` conversion Robert I. Eachus
2003-06-30  8:52     ` conversion Dmitry A. Kazakov
2003-07-03  7:03       ` conversion Robert I. Eachus
2003-07-09  7:42         ` conversion Dmitry A. Kazakov
2003-07-09 17:04           ` Robert I. Eachus [this message]
2003-07-10 10:19             ` conversion Dmitry A. Kazakov
2003-07-11  1:56               ` conversion Alexander Kopilovitch
2003-07-05  2:40     ` conversion Alexander Kopilovitch
2003-07-05  6:33       ` conversion Georg Bauhaus
2003-07-05 17:06         ` conversion Alexander Kopilovitch
2003-07-06  3:53           ` conversion Robert I. Eachus
2003-07-06  5:13             ` conversion Jeffrey Carter
2003-07-06 12:45               ` conversion Chad R. Meiners
2003-07-07  1:09             ` conversion Alexander Kopilovitch
2003-07-06 20:04           ` conversion Georg Bauhaus
2003-07-07 14:55             ` conversion Stephen Leake
2003-07-07 21:36               ` conversion Alexander Kopilovitch
     [not found] <002701c33e22$8e9deaf0$0201a8c0@win>
2003-06-29 20:15 ` conversion David C. Hoos, Sr.
  -- strict thread matches above, loose matches on Subject: below --
2003-06-29  9:41 conversion Andrew
2003-07-04 10:42 ` conversion Janeit
2003-06-28  8:46 conversion Andrew
2003-06-28  9:49 ` conversion Preben Randhol
2003-06-30 14:08 ` conversion Stephen Leake
2003-06-27 17:37 conversion Andrew
2003-06-27 17:32 ` conversion Stephen Leake
2003-06-28  2:55 ` conversion Jeffrey Carter
1998-07-22  0:00 conversion Rick
1998-07-22  0:00 ` conversion Richard Toy
1998-07-22  0:00 ` conversion Corey Ashford
1998-07-22  0:00   ` conversion Corey Ashford
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox