[plt-scheme] phase question
I have reduced more complicated code to the following:
file trial.ss ========================================
#lang scheme
(provide declare-tag use-tag)
(define-for-syntax tag-register '())
(define-for-syntax (register-tag tag)
(set! tag-register
(cons (syntax->datum tag) tag-register)))
(define-for-syntax (tag? tag)
(member (syntax->datum tag) tag-register))
(define-syntax (declare-tag stx)
(syntax-case stx ()
((_ tag)
(begin (register-tag #'tag) #'(void)))))
(define-syntax (use-tag stx)
(syntax-case stx ()
((_ tag) (tag? #'tag) #''ok)
((_ tag)
(raise-syntax-error 'tags
"unknown tag" stx #'tag))))
; of course I can leave out the check (tag? #'tag)
; and omit the error detection, but that gives rise
; to unclear error messages when wrong tags are used
; in the program I excerpted this example from.
(declare-tag a)
(declare-tag b)
(use-tag a) ; --> ok
file-use-trial.ss ======================================
#lang scheme
(require "trial.ss")
(declare-tag x)
(use-tag x) ; ok, but
(use-tag a) ; --> unknown tag
I understand that the tag-register is reset to () when invoked for different phases. Is there a way to register the tags in such a way that macro use-tag sees both those declared in trial.ss and in use-trial.ss? If I remember correctly use-tag did do that in version 370.
Thanks, Jos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080710/04ee9c8b/attachment.html>