On 21 Sep 2006, at 17:54, Eli Barzilay wrote:
> On Sep 17, Pascal Costanza wrote:
>
>> Full description of the issue:
>>
>> Section 17.6, page 113, last paragraph, states that "Using lisp-
>> transformer, defining a basic version of Common Lisp's defmacro is a
>> straightforward exercise."
>>
>> This is misleading. [...]
>
> I don't think so. I read "basic version" as the basic version that is
> commonly found in some Schemes -- no destructuring and no
> environments.
The text says "basic version of Common Lisp's defmacro", not "basic
version of some Schemes' defmacro."
The current text can be interpreted as if what lisp-transformer does
were all that Common Lisp's defmacro basically does. And that's
wrong. Implementing a full-fledged version of Common Lisp's defmacro
is certainly not a straightforward exercise.
The text can also be interpreted differently, but that's why I said
the text is "misleading", not "wrong."
> Basically this (from an old post):
>
> (define macros '())
>
> (define nothing (list "nothing"))
>
> (define (preprocess-expr expr)
> (cond
> ((not (pair? expr)) expr)
> ((eq? 'defmacro (car expr))
> (set! macros
> (cons (cons (cadr expr)
> (eval `(lambda ,_at_(cddr expr))))
> macros))
> nothing)
> ((assq (car expr) macros) =>
> (lambda (m) (preprocess-expr (apply (cdr m) (cdr expr)))))
> (else (cons (preprocess-expr (car expr))
> (preprocess-expr (cdr expr))))))
>
> (define (preprocess)
> (let loop ((expr (read)))
> (if (not (eof-object? expr))
> (let ((expr (preprocess-expr expr)))
> (if (not (eq? nothing expr))
> (begin (write expr) (newline)))
> (loop (read))))))
Huh? The text in R6RS is about implementing a subset of defmacro in
terms of syntax-case.
Pascal
--
Pascal Costanza, mailto:pc_at_p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium
Received on Thu Sep 21 2006 - 12:24:53 UTC