Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!bloom-beacon!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.c Subject: Re: Uninitialized externals and statics Message-ID: <28422@news.Think.COM> Date: 29 Aug 89 16:38:51 GMT References: <2128@infmx.UUCP> <4700042@m.cs.uiuc.edu> <1989Aug25.185428.3511@utzoo.uucp> <609@paperboy.OSF.ORG> <10831@smoke.BRL.MIL> <1392@atanasoff.cs.iastate.edu> <10859@smoke.BRL.MIL> <1403@atanasoff.cs.iastate.edu> Sender: news@Think.COM Reply-To: barmar@kulla.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 39 In article <1403@atanasoff.cs.iastate.edu> hascall@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@think.com {uunet,harvard}!think!barmar