[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] "include" filename resolution



Hello Denis:

On Mon, 8 Aug 2011, Denis Washington wrote:

> I was wondering how implementations are thought to resolve file
> names in module "include" forms: relative to the including source
> file or the current working directory? Only the former would be
> really useful IMO, but there is no mention of this concern in the
> draft. I know that file name resolution is actually out of scope
> for the report, but a sentence hinting to what is intended might
> be nice. (If every implementation interprets this differently,
> "include" becomes useless.)

I particularly like the way that Chez handles this in its system. There
are three parameteres that control searching and finding of files
through three mechanisms: importing libraries, including files, and
loading files.

source-directories : Parameter

   This parameter contains a list of pathname directory strings. INCLUDE
   and LOAD search the directories listed in SOURCE-DIRECTORIES in order
   and load the first file that can be resolved thus.

library-directories : Parameter

   This is analagous to the SOURCE-DIRECTORIES parameter, except that it
   is used as the set of base root directories when resolving library
   imports that are not already imported into the system.

library-extensions : Parameter

   This specifies the precedent for file extensions when loading files.

These parameters can be set on the command line when launching Chez, or
through environment variables, or programmatically through the parameter
interface. Moreover, Chez automatically CONSes the parent directory of a
library that it is about to load to the SOURCE-DIRECTORIES parameter
right before it automatically loads that library. This allows you to
include files in a library relative to the library's location, without
needing to explicitly mention the directory before hand, which greatly
improves the usability of automatic library importing.

 	Aaron W. Hsu

-- 
Programming is just another word for the lost art of thinking.

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports