Uninitialized externals and statics

Barry Margolin barmar at think.COM
Wed Aug 30 02:38:51 AEST 1989


In article <1403 at atanasoff.cs.iastate.edu> hascall at atanasoff.cs.iastate.edu.UUCP (John Hascall) writes:
>   If you are not going to restrict the "local alphabet" *
>   characters to a contiguous sequence of integer values it certainly
>   makes the problem of writing a portable sorting routine difficult.

>*  I was privately chided for my ethnocentric use of 'a'..'z'

Well, since you mention that you aren't talking about just US ASCII,
it's worth pointing out that the international standard 8-bit
character code DOESN'T have the alphabetic characters contiguous.  It
was designed to be a superset of 7-bit ASCII.  This prevents it from
keeping the letters contiguous, since the alphabetic characters are
surrounded by non-alphabetic characters.  All the added characters
have their high order bit on.

So, if ANSI C were to require alphabetic characters to be contiguous,
it would not be possible to implement one that also supported the
standard character encodings.  Fully general lexicographic sorting
programs can't just use the numeric character values; indeed,
different coutries that use the same alphabet may have different
ordering conventions, so you can't even use a fixed ordering.  You
need a locale-dependent character-ordering predicate to do it right.

In Common Lisp, we define a partial ordering of the alphanumeric
characters required by the standard.  We specify that the uppercase
and lowercase characters must each be ordered alphabetically, that the
digits be ordered numerically, and that the digits not be interleaved
with any of the alphabetics.  We don't, however, require that the
characters be sequential within any of the three groups of characters,
nor do we specify the relative ordering of the three groups.  These
rules were designed so that both ASCII and EBCDIC could be used.  We
also define CHAR< and related predicates to permit the program to
access the actual order of the characters in the implementation.

Barry Margolin
Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.lang.c mailing list