[plt-scheme] getting the current module directory

From: Robert Bruce Findler (robby at cs.uchicago.edu)
Date: Mon Dec 16 15:40:11 EST 2002

That's the idea, but you might want to use etc.ss's
this-expression-source-directory.

At Mon, 16 Dec 2002 15:38:58 -0500 (EST), Doug Orleans wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> 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



Posted on the users mailing list.