This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: how to define a transformer?


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]