Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!harvard!panda!genrad!decvax!decwrl!ucbvax!ernie.Berkeley.EDU!kos From: kos@ernie.Berkeley.EDU.UUCP Newsgroups: net.lang.c Subject: generalized switch Message-ID: <15093@ucbvax.BERKELEY.EDU> Date: Fri, 1-Aug-86 18:19:22 EDT Article-I.D.: ucbvax.15093 Posted: Fri Aug 1 18:19:22 1986 Date-Received: Sat, 2-Aug-86 22:16:11 EDT Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: kos@ernie.Berkeley.EDU (Joshua Kosman) Organization: University of California, Berkeley Lines: 43 Keywords: Suggestions wanted 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: etc... } (translated to C because I don't remember any PL/I ) you also had the option of switch() { case : etc. } 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 () { IS_TYPE_A(c): do_type_a(c); break; IS_TYPE_B(c): do_type_b(c); break; } But it's something I've wanted in the past in other contexts as well. Any ideas? Joshua Kosman kos@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