chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] tokenization question


From: Alejandro Forero Cuervo
Subject: Re: [Chicken-hackers] tokenization question
Date: Mon, 18 Jun 2007 20:22:56 +0000
User-agent: Mutt/1.5.13 (2006-08-11)

> How does chicken know what happened here:
> 
> csi> define
> Error: unbound variable: define
> csi> (define define (lambda () 42))
> csi> define
> #<procedure (define)>
> csi> (define)
> Error: (car) during expansion of (define ...) - bad argument type: ()
> 
>         Call history:
> 
>         <syntax>                (define)        <--

I would imagine this is what happened: *before* attempting to evaluate
your “define” function, Chicken attempts to apply all macros and
evaluate special forms (such as “(define ...)”).  So the fact that you
bind the symbol “define” is irrelevant: Chicken will try to expand
your “(define)” form and the expansion will fail (in exactly the same
way it fails when you haven't bound the “define” symbol).

The “<syntax>” part in the error report means that the error took
place during the syntactic expansion (instead of during the actual
evaluation).

To see what a certain syntax will expand to before evaluation, you can
use the “macroexpand” macro, as in:

    (macroexpand '(define x 40))

Alejo.
http://azul.freaks-unidos.net/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]