[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[plt-scheme] Chez/MzScheme difference?




	If I drop the below code into a file, and run it under MzScheme
(200a18), I get:

| Welcome to MzScheme version 200alpha18, Copyright (c) 1995-2002 PLT
| reference to undefined identifier: pity-the-poor-foo

	If I define 'syntax->list' as the identity, and run the same code under
Chez, I get 4000.

	If I bind 'pity-the-poor-foo' with a 'letrec' inside the scope of the
'macro-fu' lambda, things seem to work (see comment in code). This is a
simplified version of a problem I haven't been able to make my way around in my
continued bi-polar Scheme existance.

	I can only guess that this has to do with differences between the two
Schemes w.r.t. when macros are expanded, and what is available in the namespace
at expansion time.

	Thoughts or pointers to code/documentation appreciated.

	Thanks,
	Matt

(define pity-the-poor-foo
  (lambda (n)
    (vector->list (make-vector n))))

(define-syntax macro-fu
  (lambda (x)
    ;; Things are happier with a 'letrec' binding here.
    (syntax-case x ()
      [(_ (p v ...) body)
       (with-syntax ([(i ...)
		      (pity-the-poor-foo (length (syntax->list #'(v ...))))])
	 #'(let ()
	     'formerlyKnownAsPrince))])))

((let ([a.1 '4000])
     (letrec ([anon$3
               (lambda (p b.2) (macro-fu (p a.1) (+ a.1 b.2)))])
       (lambda () a.1))))



________________________________________________________________________
Matt Jadud                            http://www.cs.indiana.edu/~mjadud/
Current Temperature Outside Lindley Hall                 55.4 F / 13.0 C
Canterbury Weather: High 60 F / 16 C, Low 55 F / 13 C, Medium-level cloud