[plt-scheme] find-method/who

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Mar 28 12:14:23 EST 2005

At Sat, 26 Mar 2005 22:15:12 -0500, Doug Orleans wrote:
> Well, I already need to use a module that I don't have privilege over,
> namely MzLib's "class.ss".  It seems like I should not be reporting
> `find-method/who' as a free variable of every procedure that uses the
> `send' macro, because it's private to "class.ss".

This is along the lines of a path that I abandoned. For example, I
wanted errortrace to work even if it was given less privilege than
MzScheme (which includes macros that introduce references to private
variables). I couldn't make it work well enough to be useful, though.

For your purposes, a simple `identifier-exported?' predicate might be
enough. Here's a little hack that I think implements the predicate:

 (define (identifier-exported? id)
   (parameterize ([current-code-inspector (make-inspector)])
     ;; If `id' isn't exported, then attempting to expand
     ;;  an uncertified version of the identifier shouldn't work:
     (with-handlers ([exn:fail:syntax? (lambda (x) #f)])
       (local-expand (datum->syntax-object id (syntax-e id)) 
                     'expression 
                     (list #'#%top))
       #t)))

If it's not used for a macro, then `local-expand' above should be just
`expand-syntax'. (It could be implemented much more cleanly as a
primitive.)

Matthew



Posted on the users mailing list.