Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!bu.edu!transfer!lectroid!angmar.sw.stratus.com!jmann From: jmann@angmar.sw.stratus.com (Jim Mann) Newsgroups: comp.lang.c Subject: Re: The Sins of K&R Message-ID: <2487@lectroid.sw.stratus.com> Date: 27 Sep 90 12:39:08 GMT References: <31604@nigel.ee.udel.edu> <12180@crdgw1.crd.ge.com> Sender: usenet@lectroid.sw.stratus.com Reply-To: jmann@angmar.sw.stratus.com (Jim Mann) Organization: Stratus Computer, Inc. Lines: 54 In article <12180@crdgw1.crd.ge.com>, volpe@underdog.crd.ge.com (Christopher R Volpe) writes: |>In article <31604@nigel.ee.udel.edu>, shearer@cis.udel.edu (Rob Shearer) |>writes: |>|> |>|>I do this alot: |>|> |>|> ch = getch(); |>|> switch (ch) { |>|> case 'q': |>|> case 'Q': |>|> case 27 : |>|> case 13 : |>|> exit_menu = 1; |>|> break; |>|> case 'a': |>|> do_a(); break; |>|> ...etc |>|> } |> |>How about combining the "let's make break implicit" idea with the |>"lets add ranges and lists" idea and solve everybody's problems? E.g.: |> |>ch = getch(); |>switch (ch) { |> case 'q','Q',27,13: |> exit_menu=1; |> case 'a': |> do_a(); |> ...etc |>} |> This still doesn't do everything you might want. It doesn't handle the situation in which you do something for one case and then fall through to the next to do some additional stuff: switch(ch) { case 'a': do_a(); case 'b': do_a_or_b(); break; . . . } Jim Mann Stratus Computer jmann@es.stratus.com