[plt-scheme] Bug in Syntax Certification?
Hello,
I'm seeing a weird error message when I try to use iteration macros
outside the module I defined them in. For example, the following
breaks (in the scheme language in DrScheme, version 4.0.0.1-
svn13jun2008):
(require (planet wmfarr/simple-matrix:1/matrix))
(for/list ((x (in-matrix (matrix* 2 2 1 2 3 4)))) x)
with the error
compile: access from an uncertified context to unexported variable
from module: "/Users/farr/Documents/code/simple-matrix/matrix.ss" in:
matrix-elts
There are two weird things about this error:
1. matrix-elts is exported from the matrix.ss module.
2. I haven't been playing with certifying identifiers at all (in fact,
I have only a vague notion of what certifying an identifier means).
Is this because I've used define-sequence-syntax to define in-matrix
inappropriately (the code for in-matrix and its companion procedure
*in-matrix is given below)? Is this a problem with the syntax
expander in Friday's SVN? Should I just file this as a bug in the bug
reporter, or is it a quick fix?
Sorry for the trouble, and thanks for any help you all can give me!
Will
-----------------------
Code for in-matrix:
(define (*in-matrix m)
(make-do-sequence
(lambda ()
(values
(lambda (k)
(vector-ref (matrix-elts m) k))
add1
0
(lambda (k) (< k (* (matrix-rows m) (matrix-cols m))))
(lambda (elt) #t)
(lambda (k elt) #t)))))
(define-sequence-syntax in-matrix
(lambda () (syntax *in-matrix))
(lambda (stx)
(syntax-case stx ()
(((id) (_ matrix-expr))
(syntax/loc stx
((id) (in-vector (matrix-elts matrix-expr)))))
(((i-id j-id elt-id) (_ matrix-expr))
(syntax/loc stx
((i-id j-id elt-id)
(:do-in
(((m) matrix-expr)) ;Outer bindings.
#t ; Outer check
((i-id 0) (j-id 0) (rows (matrix-rows m)) (cols (matrix-
cols m))) ;Loop id
(< i-id rows) ; Pos-guard
(((ip1) (add1 i-id)) ((jp1) (add1 j-id)) ((elt-id) (matrix-
ref m i-id j-id))) ; Inner-id.
#t ; Pre-guard
#t ; Post-guard
((if (>= jp1 cols) ip1 i-id) (if (>= jp1 cols) 0 jp1) rows
cols))))))))