generalized switch

Dave Lukes dave at inset.UUCP
Wed Aug 13 21:28:17 AEST 1986


FLAME WARNING:
this article contains statements of a possibly insulting/inflammatory nature:
no further warnings will be given.

In article <86900006 at haddock> karl at haddock.UUCP writes:
>I think one should be able to specify a list.  "case 1,4,10:" is neater than
>"case 1: case 4: case 10:",

Sure, but
a)	is ``neatness'' the only criteria for a language feature??
	What about usefulness??
b)	I never actually type large case lists,
	I just type the constants then use an editor to insert
	the ``case''s and the ``:''s.

>Better yet would be a list of ranges.  "case 'a' to 'z', 'A' to 'Z':"
>requires 52 labels in the current syntax; this is where I normally rewrite
>as if-else.  (Yes, I know that's better anyway because I can use the more
>portable test isletter().  But there are other uses for range cases, and
		 ^^^^^
One would have thought that someone proposing extensions to C would know
the correct name: isalpha().
Also: what ``other uses''?
First you suggest a way of using something which you admit can be done better
in other ways, then you suggest it has ``other uses'' without saying what
they are!!
>one could always "#define UPPER 'A' to 'I', 'J' to 'R', 'S' to 'Z'" for
>EBCDIC systems, to retain portability.)  It should also be possible to
		    ^^^^^^^^^^^^^^^^^^

So that's your definition of ``portability''??
``It works on ASCII and EBCDIC''.
This is a worldwide network (not all of us speak ``English''
and spend $).

What happens when we introduce more (i.e. international) character sets??
(-:Don't you care, or do you make your money by porting non-portable code? :-)

>specify open-ended ranges, to allow things like "switch (strcmp(s, t)) {
>case LT: ... case EQ: ... case GT: ... }" where LT and GT are #define'd as

What's wrong with ``if''??

>intervals extending to minus and plus infinity.
				       ^^^^^^^^
What is ``infinity''?
This just seems like another encouragement to non-portability.

In summary:
the suggested ``feature(s) are useful only if you intend to write non-portable
code or save a few seconds typing and thought:
we have enough problems already with non-portabilities in C code without
adding more rope for turkeys to hang themselves with.

>Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint
					    ^^^^^^^^^^^^^^^^
(-:(-: From what you have said, I think you should be forced to withdraw your
.signature on the grounds of misrepresentation!
:-):-):-):-):-):-):-):-):-):-)

>*   "[a,b)" is the American notation for a half-open interval.  The European
>    notation is "[a,b[", which would be even worse.

Actually: the ``European'' (by no means universally European) notation is a
LOT better: you don't have to stare at the equation trying to disambiguate
different kinds of parenthesis (especially useful if your printer's
character set is lousy, or the copy is badly handwritten),
although I'm used to the ``American'' notation, which ``looks nicer''.
-- 

		Dave Lukes. (...!inset!dave)

``Fox hunting: the unspeakable chasing the inedible'' -- Oscar Wilde



More information about the Comp.lang.c mailing list