generalized switch

kos at ernie.Berkeley.EDU.UUCP kos at ernie.Berkeley.EDU.UUCP
Sat Aug 2 08:19:22 AEST 1986

One of my only memories from a brief stint as a PL/I programmer years ago
was the pleasure of using a more general switch structure than C allows.
In addition to the standard
	switch (var) {
		case value:
		case value:
		}		(translated to C because I don't remember
					any PL/I )

you also had the option of 
	switch() {
		case <boolean-expr>:
if you wanted to test something other than the value of a particular variable.

I'm wondering whether any netland gurus have elegant suggestions for ways
of dummying up such a construct. The particular case at hand involves some
macros that look like:

#define IS_TYPE_A(c)	(c==this||c==that)
#define	IS_TYPE_B(c)	((c==the_other||c==your_mother) && c != rambo)
and so on. Now what I need is
	switch () {

But it's something I've wanted in the past in other contexts as well.
Any ideas?

	Joshua Kosman
	kos at ernie.berkeley.EDU

	"When I was young people used to tell me, 'When you're 50 you'll
	understand.' Well, now I'm 50. I don't understand a thing."
				-- Erik Satie

More information about the Comp.lang.c mailing list