[plt-scheme] getting the current module directory

From: Doug Orleans (dougo at ccs.neu.edu)
Date: Mon Dec 16 15:38:58 EST 2002

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)
		     stx (current-load-relative-directory)))))
  (provide *dir*))

This seems to do the trick:

Welcome to MzScheme version 202.6, Copyright (c) 1995-2002 PLT
> (current-directory)
> (require "subdir/foo.scm")
> *dir*

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

Posted on the users mailing list.