[plt-scheme] Expansion of `case' in context with `else' bound

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Tue Oct 31 18:11:57 EST 2006

Eli Barzilay skrev:
> On Oct 31, Casey Klein wrote:
>> The expansion of the expression 
>>    (let ([else #f]) (case 'foo [else 42])) 
>> fails with the error "case: bad syntax (not a datum sequence) in:
>> else."
>> Is there a reason that a binding for the `else' identifier here must
>> prevent the use of an "else clause" in a case expression?
> Consider the same with `cond':
>   (let ([else #f]) (cond ... [else 42]))
> In mzscheme, the local binding overrides the keyword.  This is a
> result of comparing identifiers rather than the symbol that was used
> in the source.

Casey, the relevant chapter and verse of R5RS is:

   4.3 Macros

    The syntactic keyword of a macro may shadow variable bindings, and
    local variable bindings may shadow keyword bindings.

Note also that in section 2.1 on identifiers, that there are no
reserved identifiers in Scheme.

That is, what you saw in your example is the logical consequence of
lexical scope.

Jens Axel Søgaard

Posted on the users mailing list.