From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_40,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Xref: utzoo comp.software-eng:3231 comp.lang.ada:3494 comp.lang.c:27040 comp.lang.fortran:2994 comp.lang.lisp:2947 comp.lang.misc:4515 comp.lang.modula2:2202 comp.lang.pascal:3247 comp.lang.scheme:1183 Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucbvax!Compass.COM!worley From: worley@Compass.COM (Dale Worley) Newsgroups: comp.software-eng,comp.lang.ada,comp.lang.c,comp.lang.fortran,comp.lang.lisp,comp.lang.misc,comp.lang.modula2,comp.lang.pascal,comp.lang.scheme Subject: Case statements in sane languages Message-ID: <9003191549.AA01608@sn1987a.compass.com> Date: 19 Mar 90 15:49:40 GMT Sender: daemon@ucbvax.BERKELEY.EDU List-Id: From: sanders@sanders.austin.ibm.com (Tony Sanders) How do you do this in ADA? switch(n) { case 0: count++; case 1: ocount++; case 2: printf("%d %d\n",count,ocount); break; default: printf("unknown n\n"); break; } See how I left out the breaks on purpose. In ADA you wouldn't be able to do this without duplicating either the case-expression (they aren't always simple numbers) or the statements. In this case, duplicating the statements wouldn't be hard enough to worry about. If the bodies of the cases were large enough to make it hard, you can write a local procedure, and just call it from several cases. (Since Ada has nested procedures, you can write a procedure that has access to local variables.) The 11th commandment: "Thou shalt use lint" In Ada (or any sane language), "Lint" is called "the compiler". Dale Worley Compass, Inc. worley@compass.com -- Why are you RUNNING? Cerebus just wants to KILL you a little...