[prev in list] [next in list] [prev in thread] [next in thread] 

List:       racket-users
Subject:    [plt-scheme] Expansion of `case' in context with `else' bound
From:       jensaxel () soegaard ! net (=?ISO-8859-1?Q?Jens_Axel_S=F8gaard?=)
Date:       2006-10-31 23:11:57
Message-ID: 4547D83D.10603 () soegaard ! net
[Download RAW message or body]

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



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic