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,5e54ec0ce937978 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!news.in2p3.fr!in2p3.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: String literals and wide_string literals - how? Date: Tue, 22 May 2007 17:32:54 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1177063665.093083.241580@e65g2000hsc.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1179873054 20851 69.95.181.76 (22 May 2007 22:30:54 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 22 May 2007 22:30:54 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Xref: g2news1.google.com comp.lang.ada:15886 Date: 2007-05-22T17:32:54-05:00 List-Id: "David Thompson" wrote in message news:s71253phu0md9cslvmq2573m2uiqmfu7lo@4ax.com... > On Fri, 20 Apr 2007 16:02:55 -0400, Robert A Duff > wrote: ... > > OK, it's not weird. It's quite elegant, in fact, from at least one > > point of view -- a character type is "just" an enumeration of the > > character literals. > > > > But I'll bet it _seems_ weird to anyone who doesn't know Ada well. Are > > there any other languages that have this sort of thing? Many folks > > presented with the above will assume type Bit above is a subtype of > > Character, or derived from it. That's why I mentioned that > > Bit'Size = 1, so the OP would understand that '0' here is not Ascii (or > > Latin-1, or whatever) '0'. > > > Pascal does have CHAR as a system-provided enumerated type. > And (normal, nonvarying) STRING as (just) array of char, although it > doesn't have the features for all array types that make Ada string > types (more) convenient. But this isn't relevant; we weren't talking about only about string being "array of character", but rather that you can define *new* character types which then can be used in "array of new_char" to get the same behavior as string (string literals and the like). I'm quite sure Pascal has no similar facility to that. My example was: type Roman is ('I', 'V', 'X', 'L', 'C'); type Roman_Numeral is array (Positive range <>) of Roman; Eight : Roman_Numeral := "VIII"; "Roman" here is a character type, but there is no way to think of it as a subtype of "Character" (for one thing, the literals have a different ordering - 'C' > 'X', for instance). The fact that you can then use this new type to get something that works like a String is what is interesting. Randy.