[plt-scheme] require with custom modules
2007/11/10, Jean-Pierre Lozi <jean-pierre at lozi.org>:
> 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?
I'm not familiar with define-macro, I only use define-syntax, that's
the reason why I missed the point.
I don't want something more complex, your macro does exactly what I want.
I my main file, I defined a a-list of path with (build-path
(current-directory) dir) and I wrote a function get-path who merely
apply assoc on that a-list, so from any file loaded or required by the
main file, I can use my (get-path dir) to get the full path to a
specified dir.
Thanks a lot,
--
Cyprien Nicolas