Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!prls!pyramid!pesnta!valid!sbs From: sbs@valid.UUCP (Steven Brian McKechnie Sargent) Newsgroups: net.lang.mod2 Subject: Re: A Long Note on the Trichotomous String Comparison Example Message-ID: <422@valid.UUCP> Date: Thu, 10-Jul-86 01:28:39 EDT Article-I.D.: valid.422 Posted: Thu Jul 10 01:28:39 1986 Date-Received: Fri, 11-Jul-86 21:37:40 EDT References: <12221138454.23.PATTIS@WASHINGTON.ARPA> Organization: Valid Logic, San Jose, CA Lines: 29 I've been idly interested in Modula-2 for a little while, especially since I admire the author of the decwrl compiler (Michael Powell) as a fellow of fine judgement in these matters. However, given the length of discussion required to solve the rather trivial problem of string comparison, I'm very concerned! Perhaps I will delay the plunge into strongly typed languages a little longer, and save some wear and tear on my keyboard. I'll close with a re-implementation of the UNIX(TM) library classic strcmp, which assumes NUL-termination for every string, and does not attempt to keep around a separate "length" field. /* * Return greater than, equal to, or less than 0 depending on whether * s is greater than, equal to, or less than t. */ strcmp(s, t) register char *s, *t; { while (*s++ == *t) if (*t++ == 0) return 0; return *--s - *t; } S. (TM) UNIX is a trademark of my cat.