[plt-scheme] Interesting module/macro interactions
Hi all,
I've got an interesting problem with PLT Scheme 202.3
vs 203.4 and SchemeUnit. The about-to-be-released
version of SchemeUnit allows you to define your own
assertions.
(define-assertion (name param ...) body ...)
expands into
(begin
(define-syntax (name param ...) body ...)
(define (name* param ...) body ...))
Note that name is defined as a macro, and name* as a
function (for those times when you want to use
assertions as functions). When trying to test this in
202.3 I get an error:
module: identifier originates in a different module
at: good* in: (define-values (good*) (opt-lambda
((message #f)) (if (begin #t) #t (fail-assertion
"good" #f mes...
which I'm fairly sure relates to wackiness fixed in
203.4 However, it appears 203.4 doesn't work in a
different way. SchemeUnit doesn't even execute
anymore:
Welcome to MzScheme version 203.4, Copyright (c)
1995-2003 PLT
assert.ss:4:1: module: provided identifier not defined
or imported at: assert-eqv?* in: (#%plain-module-begin
(require-for-syntax mzscheme) (require (lib "etc.ss"))
(require-for-syntax ...
Looking at the define-assertion macro, it uses name
directly but constructs name*. It appears the module
expander is not realising that name* (assert-eqv?*
above) is created by the macro and so doesn't believe
the identifier exists.
The complete define-assertion macro is
(define-syntax define-assertion
(lambda (stx)
(syntax-case stx ()
((define-assertion (name param ...) expr ...)
(with-syntax (((reported-name function-name)
(let ((reported-name
(symbol->string
(syntax-object->datum (syntax name)))))
(list reported-name
(string->symbol
(string-append reported-name "*"))))))
(syntax/loc stx
(begin
(define-syntax name
(lambda (stx)
(syntax-case stx ()
((name param ...)
(with-syntax ((location
(location-list stx)))
(syntax/loc stx
(if (begin expr ...)
#t
(fail-assertion
reported-name
'location
#f
(current-continuation-marks)
param
...)))))
((name param ... message)
(with-syntax ((location
(location-list stx)))
(syntax
(if (begin expr ...)
#t
(fail-assertion
reported-name
'location
message
(current-continuation-marks)
param
...))))))))
(define function-name
(opt-lambda (param ... [message #f])
(if (begin expr ...)
#t
(fail-assertion reported-name
#f
message
(current-continuation-marks)
param
...)))))))))))
The question is: is this a MzScheme bug or is it a
"don't do that" (ie SchemeUnit) bug. The latter
option would be a real bummer...
Ta,
Noel
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com