This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: how to define a transformer?
- To: Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Subject: Re: how to define a transformer?
- From: Jost Boekemeier <jostobfe at linux dot zrz dot TU-Berlin dot DE>
- Date: 09 May 2000 21:23:35 +0200
- Cc: guile at sourceware dot cygnus dot com
- References: <m3itwpghnu.fsf@kei.cwru.edu> <p2titwoq0o9.fsf@ruebe.zrz.tu-berlin.de> <m3d7mw1xwz.fsf@kei.cwru.edu>
Keisuke Nishida <kxn30@po.cwru.edu> writes:
> I just wondered why the transformer (or syntax) is called twice every
> time I evaluate an expression.
No idea, really.
> > However, the module system will change anyway [TM]. :)
> I hope that comes before long...
May happen in this century. :) I'll post my module proposal
in jun/jul this year.
> As long as there is a way to transform an expression at this level,
> I'll be happy.
Yes, the eval:transformer is gone. But we'll find another way to support
what you want, don't worry.
> (define (transformer x)
> (let ((lisp-symbol? (lambda (o) (eq? (string-ref o 0) #\$)))
> (lisp-value (lambda (o) (list 'lisp-value
> (string->symbol (substring o 1))))))
> (if (and (symbol? x) (lisp-symbol? x))
> (lisp-value x)
> (letrec ((trans! (lambda (x)
> (cond ((pair? x)
> (if (symbol? (car x))
> (if (lisp-symbol? (car x))
> (set-car! x (lisp-value (car x))))
> (trans! (car x)))
> (trans! (cdr x)))))))
> (trans! x)
> x))))
Hmm, I think you should insert a (let ((x (copy-tree x)))) before
rewriting x. Why so complicated anyway, doesn't a procedure with
setter + some macro do what you want?
Jost