On Nov 9, 2008, at 2:28 PM, marcomaggi wrote:

this fails:

(check
 (let ()
   (define (slurp arg)
     arg)
   (define-macro (proof a . args)
     (slurp
       `(,a ,(+ 1 (car args)) ,(cadr args))))
   (proof list 123 'three))
 => '(124 three))

with:

Unhandled exception:
 Condition components:
   1. &who: slurp
   2. &message: "identifier out of context"
   3. &syntax:
       form: slurp
       subform: #f

Correct.  You are using a run-time variable at expand time.
[at the time ikarus is expanding your code, it cannot know
the value of slurp which is computed later, after the whole
code is expanded and the expressions and definitions are
evaluated.]

You can use "slurp" in one of two ways:

1. If you want to use slurp at expand time, you should write
it like:

(check
 (let ()
   (define-macro (proof a . args)
     (define (slurp arg)
       arg)
     (slurp
       `(,a ,(+ 1 (car args)) ,(cadr args))))
   (proof list 123 'three))
 => '(124 three))

2. If you want to use slurp at run time, you should write
it like:

(check
 (let ()
   (define (slurp arg)
     arg)
   (define-macro (proof a . args)
     `(slurp (,a ,(+ 1 (car args)) ,(cadr args))))
   (proof list 123 'three))
 => '(124 three))


Aziz,,,

Reply via email to