[plt-scheme] module name resolution, symlinks, and path normalization

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Tue Jun 20 11:10:59 EDT 2006

>> The scenario I run into in my own project involves cases where, in 
>> dynamically generated code, I'm constructing module paths using 
>> this-expression-source-directory
> I worry about `this-expression-source-directory', and you've provided a 
> good example of the problem.
> To locate something in a collection, use `collection-path' instead. If 
> you have some code that may or may not be installed in a collection, 
> then I'm afraid I don't have a good answer for you.

Hi Matthew,

Both, unfortunately.  I did find a workaround that doesn't involve 
overriding the module name resolver (which itself comes with its own set 
of messy issues!), so I can work around this.  However, this is a really 
big gotcha for anyone writing dynamic code.  When my head is clearer and I 
can think of a concise example, I'll try writing something up in the 

As a first pass at summarizing the problem: the triggering condition was 
the naive use of a directory-constructing function, like 
this-expression-source-directory, to build a module path.  I was in the 
context of a symbolically-linked directory.  I intended to use this path 
to refer to an already-loaded module, but had no guarantee that the 
dynamically-constructed module path referred to that already-loaded 
module.  Consequently, when I later used module-name-resolver and 
namespace-attach-module to attach to a child namespace, things broke 
because of the path difference.

> In other words, the intended connection between module names and files 
> is not that each file corresponds to a module, but that each file *path* 
> corresponds to a module. The difference is subtle --- and having a 
> module<->file mapping might be nicer, but I don't think it's tractable 
> in general.

Yeah; I was trying to think of other possibly ways one might handle this. 
A perverse part of my brain said "Why not have programmers embed UUIDs to 
each module to allow unambiguous reference?  It should work, but it would 
be very ugly."  At which point I laughed at myself, since that's what I 
dislike so much about 'package' declarations in other languages.  I can't 

Anyway, thanks again!

Posted on the users mailing list.