I&#39;ve been feeling pretty good about my macro-fu recently so I gave it a shot (I havent looked at anyone&#39;s solutions yet). This seems to pass all the test cases but I dont think it passes the &quot;linear&quot; requirement yet.<br>
<br><span style="font-family: courier new,monospace;">(define-syntax (cas-cad-e stx)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  (syntax-case stx ()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    [(_ e ((v) exp ...))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     (with-syntax ([break (datum-&gt;syntax stx &#39;break)])</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">       #&#39;(call/cc</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">          (ë (break)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            (if (equal? e v)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                (begin exp ...)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                (void)))))]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    [(_ e ((v1) exp1 ...) ((v2) exp2 ...) ...)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">     (with-syntax ([break (datum-&gt;syntax stx &#39;break)])</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">       #&#39;(call/cc</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">          (ë (break)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            (if (equal? e v1)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                (begin exp1 ... exp2 ... ...)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                (cas-cad-e e ((v2) exp2 ...) ...)))))]))</span><br>
<br><br><br><br><br>On Fri, Oct 8, 2010 at 9:04 PM, Shriram Krishnamurthi &lt;<a href="mailto:sk@cs.brown.edu">sk@cs.brown.edu</a>&gt; wrote:<br>&gt; One of my students recently sent me this needless email message:<br>&gt;<br>
&gt;&gt; Well, how would you do switch fall-through in Scheme? Could you<br>&gt;&gt; write a version of the case statement that does that?<br>&gt;<br>&gt; Since the honor of Racket was at stake (yes, we can have all the same<br>
&gt; stupid features the scripting languages have!), I wrote down the code<br>&gt; for this, and realized it would make a cute little macro exercise.<br>&gt;<br>&gt; Spec: define a case construct syntactically just like that of Racket.<br>
&gt; In terms of semantics:<br>&gt;<br>&gt; - each branch automatically falls through to the next,<br>&gt;<br>&gt; - the last one returns its answer since it has no next clause, and<br>&gt;<br>&gt; - any branch can contain (break &lt;expr&gt;), which evaluates &lt;expr&gt; and<br>
&gt; returns its value as that of the entire case.<br>&gt;<br>&gt; In honor of its behavor, we&#39;ll call this cas-cad-e.  Thus,<br>&gt;<br>&gt; (define (cas1 v)<br>&gt;   (cas-cad-e v<br>&gt;            ((1) (display &quot;1&quot;))<br>
&gt;            ((2) (display &quot;2&quot;) (break 2)<br>&gt;            ((3) 3))))<br>&gt;<br>&gt; (cas1 1) ==&gt; 2       (and prints &quot;12&quot;)<br>&gt; (cas1 2) ==&gt; 2       (and prints &quot;2&quot;)<br>&gt; (cas1 3) ==&gt; 3       (and prints nothing)<br>
&gt; (cas1 4) ==&gt; &lt;void&gt;  (and prints nothing)<br>&gt;<br>&gt; If anyone wants to look at my solution, here it is:<br>&gt;<br>&gt;  <a href="http://github.com/shriram/cas-cad-e">http://github.com/shriram/cas-cad-e</a><br>
&gt;<br>&gt; Of course, those who know how to do this don&#39;t need to peek, and those<br>&gt; who don&#39;t shouldn&#39;t.<br>&gt;<br>&gt; Shriram<br>&gt; _________________________________________________<br>&gt;  For list-related administrative tasks:<br>
&gt;  <a href="http://lists.racket-lang.org/listinfo/users">http://lists.racket-lang.org/listinfo/users</a><br>&gt;<br><br>