[plt-scheme] Require and a path

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Apr 5 09:41:03 EDT 2005

At Mon, 4 Apr 2005 22:51:06 -0700, "Alex Peake" wrote:
> Why does:
> 
> (require (file (build-path "Dev" "CodeGen" "string-utils.scm")))
> 
> Not work then?

Sub-forms of `require' are not expression positions. When a string is
used to name a module, it must be a literal string.

For the above example, I think you want just

 (require "Dev/CodeGen/string-utils.scm")

When `file' isn't used, a string is treated like a URL-style relative
path. That is, even if the filesystem doesn't use "/" as the separator,
the above means: "string-utils.scm" in the "CodeGen" subdirectory of
the "Dev" subdirectory of the directory containing this module.

As in URLs, you can use ".." to go up, so

 (require "../string-utils.scm")

means: "string-utils.scm" in the parent directory of this module's
directory.

Matthew



Posted on the users mailing list.