[plt-scheme] case-statement in mzscheme 3.99 and drscheme interaction

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Nov 28 20:55:15 EST 2007

Thanks for tracking down this bug, Danny! I note that the zero-clause
case has a similar bug.

A `let' wrapper isn't quite the right solution, because it creates an
internal-definition position. I added an `#%expression' wrapper around
the troubled `begin's.

Matthew

At Wed, 28 Nov 2007 18:40:24 -0500 (EST), Danny Yoo wrote:
> Hi everyone,
> 
> 
> Minor issue: the following snippet:
> 
> ;;;;;;;;;;;;;;
> #lang scheme
> (case 42
>    [else #f])
> ;;;;;;;;;;;;;;
> 
> produces the following output in DrScheme 3.99:
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> Welcome to DrScheme, version 3.99.0.3-svn28nov2007 [3m].
> Language: Module; memory limit: 128 megabytes.
> 42
> #f
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> We're seeing '42' because the case macro is force evaluation of the thing 
> we're casing against by putting it in a BEGIN.  This looks a little weird 
> when we run in the DrScheme interaction window since DrScheme tries to 
> show the multiple expression values when there's a toplevel BEGIN.
> 
> 
> Here's a proposed fix that uses LET instead to avoid the weirdness with 
> the Interaction window:
> 
> #####################################################################
> 
> dyoo at kfisler-ra1:~/local/plt-svn-2$ svn diff collects/scheme/private/more-
> scheme.ss
> 
> Index: collects/scheme/private/more-scheme.ss
> ===================================================================
> --- collects/scheme/private/more-scheme.ss	(revision 7852)
> +++ collects/scheme/private/more-scheme.ss	(working copy)
> @@ -23,7 +23,7 @@
>   	((_ v)
>   	 (syntax (begin v (void))))
>   	((_ v (else e1 e2 ...))
> -	 (syntax/loc x (begin v e1 e2 ...)))
> +	 (syntax/loc x (let ([x v]) e1 e2 ...)))
>   	((_ v ((k ...) e1 e2 ...))
>   	 (syntax/loc x (if (case-test v (k ...)) (begin e1 e2 ...) 
> (void))))
>   	((_ v ((k ...) e1 e2 ...) c1 c2 ...)
> 
> 
> #####################################################################
> 
> I hope this helps!
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.