[plt-scheme] require with custom modules

From: Jean-Pierre Lozi (jean-pierre at lozi.org)
Date: Sat Nov 10 14:08:20 EST 2007

On Nov 10, 2007 7:34 PM, Cyprien Nicolas <c.nicolas at gmail.com> wrote:
> Hi
> I'm building an application to compile a subset of BASIC expressions
> into scheme (my Interpretation course at the University of Nice), I
> have defined several modules to handle the compilation process (lexer,
> parser, etc).
> The application is launched by a main.scm file located in the root
> directory of the app.
> The GUI is located in a gui/ dir, and the modules in the parse/ dir
> So I use (load (build-path (current-directory) "gui" "gui.scm") to
> load the GUI, and I'd like to do the same for require my modules,
> because gui.scm needs to load some of them.
> I don't want to use the form (require (file "../parse/parser.ss"))
> because I hate using .. in file paths, and depending on where the
> require is made, every path will be different.

If using ".." in file paths is the problem, why don't you simply use a
macro? For instance :

(define-macro (my-require . args)
  (let ((result (path->string (apply build-path (map eval args)))))
   `(require (file ,result))))

(my-require (current-directory) 'up "parse" "parser.ss")

Or maybe do you need something more complex?

Jean-Pierre Lozi
mailto:jean-pierre at lozi.org

Posted on the users mailing list.