This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

macro expansion bug?


I was trying to learn some tricks shown in CPS-style macro programming
and picked up the example shown by Oleg:

(define-syntax mreverse
  (syntax-rules ()
    ((_ . args)
     (letrec-syntax
	 ((go
	   (syntax-rules ()
	     ((_ (first . rest) result)
	      (go rest (first . result)))
	     ((_ () result)
	      'result)))
	  (aux
	   (syntax-rules ()
	     ((_ (elem . tail))
	      (go (elem . tail) ()))
	     ((_ elem . tail)
	      (go (elem . tail) ())))))
       (aux . args)))))


This does the thing like reverse does but in a "CPS" way to sidestep
some of the problems in syntax-rules's limitation. 

So (mreverse (1 2 3 4)) should return (4 3 2 1). MzScheme, MIT Scheme,
and Chicken return this answer. However, both Kawa and Bigloo 
failed to produce the answer. Bigloo is worse: it doesn't see
how to expand 'go' here. Kawa return  the symbol 'result.

Is it a bug? Or my understanding of syntax-rules still leaves 
something to be desired?

Thanx!


Wen-Chun


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