comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: String literals and wide_string literals - how?
Date: Tue, 22 May 2007 17:32:54 -0500
Date: 2007-05-22T17:32:54-05:00	[thread overview]
Message-ID: <f2vquu$kbj$1@jacob-sparre.dk> (raw)
In-Reply-To: s71253phu0md9cslvmq2573m2uiqmfu7lo@4ax.com

"David Thompson" <dave.thompson2@verizon.net> wrote in message
news:s71253phu0md9cslvmq2573m2uiqmfu7lo@4ax.com...
> On Fri, 20 Apr 2007 16:02:55 -0400, Robert A Duff
> <bobduff@shell01.TheWorld.com> 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.






  reply	other threads:[~2007-05-22 22:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-20 10:07 String literals and wide_string literals - how? Gerd
2007-04-20 14:33 ` Adam Beneschan
2007-04-20 14:55 ` Robert A Duff
2007-04-20 19:16   ` Randy Brukardt
2007-04-20 20:01     ` Adam Beneschan
2007-04-20 20:41       ` Dmitry A. Kazakov
2007-04-20 20:02     ` Robert A Duff
2007-05-21  2:33       ` David Thompson
2007-05-22 22:32         ` Randy Brukardt [this message]
2007-05-23 18:42           ` Jeffrey R. Carter
     [not found]             ` <f324h5$fna$1@f04n12.cac.psu.edu>
2007-05-24 21:15               ` Jeffrey R. Carter
2007-05-23  2:27         ` Keith Thompson
2007-07-01  1:00           ` David Thompson
2007-05-23 12:28         ` brian.b.mcguinness
2007-04-20 20:48     ` Dmitry A. Kazakov
2007-04-20 22:09   ` Jeffrey R. Carter
2007-04-21  9:41     ` Simon Wright
2007-04-22  0:35       ` Jeffrey R. Carter
2007-04-22  9:45         ` Simon Wright
2007-04-22 20:15           ` Jeffrey R. Carter
2007-04-22 21:18             ` Simon Wright
2007-04-23  1:44               ` Jeffrey R. Carter
2007-04-22  1:00     ` Robert A Duff
2007-04-20 14:58 ` Georg Bauhaus
replies disabled

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