comp.lang.ada
 help / color / mirror / Atom feed
From: mob@mit-amt.MEDIA.MIT.EDU (Mario O. Bourgoin)
Subject: Re: Case statements in sane languages
Date: 19 Mar 90 19:38:50 GMT	[thread overview]
Message-ID: <1925@mit-amt.MEDIA.MIT.EDU> (raw)
In-Reply-To: 9003191549.AA01608@sn1987a.compass.com

I feel I must interject a some Scheme code in this otherwise C-based
discussion cross-posted to comp.lang.scheme.  In Scheme, there's a
control construct called CASE which is much like C's SWITCH except
that doesn't allow the clauses to be cascaded but it does allow
multiple constants per clause.  It's easy to imagine a CASE-EVERY (in
the spirit of ZETALISP's COND-EVERY) very similar to CASE but that
evaluates every clause whose constant part includes the key.  The
resulting structure passes control more explicitly than its C
equivalent, and yet remains simple enough to encourage programmers to
use it.  For example:

	(case-every (0
		     (1+ count))
		    ((0 1)
		     (1+ ocount))
		    ((0 1 2)
		     (writeln count ocount))
		    (else
		     (writeln "unknown n")))

--Mario

  reply	other threads:[~1990-03-19 19:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-03-19 15:49 Case statements in sane languages Dale Worley
1990-03-19 19:38 ` Mario O. Bourgoin [this message]
1990-03-20 16:02   ` Case statements: Error in my reply Mario O. Bourgoin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox