[plt-scheme] getting the current module directory
I need to get a module's directory from inside the module. Here's
what I came up with:
(module foo mzscheme
(define *dir*
(let-syntax ((current-module-directory
(lambda (stx)
(datum->syntax-object
stx (current-load-relative-directory)))))
(current-module-directory)))
(provide *dir*))
This seems to do the trick:
Welcome to MzScheme version 202.6, Copyright (c) 1995-2002 PLT
> (current-directory)
"/home/dougo/fred/scratch"
> (require "subdir/foo.scm")
> *dir*
"/home/dougo/fred/scratch/subdir/"
What I'm wondering is, is this a clever hack or a gross misuse of macros?
Is there a better way to do it?
--dougo at ccs.neu.edu