🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3628

Re: Switch switch

#3628
From: Richard A. O'Keefe
Date: Thu, 03 Aug 1995 04:14
49 lines
2305 bytes
jim.fleming@bytes.com (Jim Fleming):
> Does anyone want to be able to write....???
> 
> 	switch (aString) {
> 		...
> 	case "hello":

I was once on a committee that (re-)designed an Algol-like language.
If I remember correctly, we decided to do this.

Since then people have belatedly realised that while English is the
most widely used second language, the majority of people in the world
still don't speak it, and we'd still like to be able to sell them
computers and programs.  I know I get p***ed off having to cope with
dates in American form instead of sensible English form or even better
ISO 8601 form, and I remember using a program that produced error
messages in French and not enjoying that very much even though I coped.

One of the big lessons for today's international programming is
    "don't put message literals in code".
There is a fair literature on the subject now.  See for example
	Developing and Localizing International Software"
	Madell, Parsons, & Abegg
	Hewlett-Packaed Professional Books
	ISBN  0-13-300674-3
	(Price in Australia AUD 67.95, which is rather steep)

A programming language construct that encourages you do to the wrong
thing is just what we don't need.

wirzeniu@cc.Helsinki.FI (Lars Wirzenius) writes:

>Would this be equivalent to

>	aString == "hello"	(compare pointers)
>	strcmp(aString, "hello") == 0	(compare strings)
>	strcasecmp(aString, "hello") == 0	(case in-sensitive comparison)

>or something else?

For example, would it be equivalent to

	strcoll(aString, "hello") == 0

and did you expect your switch statement to be locale-dependent?
-- 
"conventional orthography is ... a near optimal system for the
 lexical representation of English words." Chomsky & Halle, S.P.E.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
Technical Details
Message-ID: <3vpie8$fbc@goanna.cs.rmit.edu.au>
Path: arc1-ca.pugleaf.net!goanna.cs.rmit.edu.au!not-for-mail
References: <3vn92m$oqt@news1.mcs.net> <3vno05$il7@kruuna.helsinki.fi>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!goanna.cs.rmit.edu.au!not-for-mail
From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Newsgroups: comp.std.c
Subject: Re: Switch switch
Date: 3 Aug 1995 14:14:00 +1000
Organization: Comp Sci, RMIT, Melbourne, Australia
Message-ID: <3vpie8$fbc@goanna.cs.rmit.edu.au>
References: <3vn92m$oqt@news1.mcs.net> <3vno05$il7@kruuna.helsinki.fi>
NNTP-Posting-Host: goanna.cs.rmit.edu.au
NNTP-Posting-User: ok
X-Newsreader: NN version 6.5.0 #0 (NOV)