[MLton] mlbs and soft and hard links

Stephen Weeks MLton@mlton.org
Sun, 15 Aug 2004 08:10:13 -0700


There are a couple of subtleties about the semantics of mlbs that are
worth clarifying and explaining in the informal section of the mlb
docs.

As I understand it, the meaning of an mlb file as a soft link is to
define the contents of the mlb file to be the contents of the link
(after following until you reach a file).  For example, suppose we
have the following four files.

z.mlb: --> a/a.mlb  (soft link)
a.sml:
  print "outer\n";
a/a.mlb:
  $(MLTON_ROOT)/basis/basis.mlb
  a.sml
a/a.sml
  print "inner\n";

Then the program produced by compiling z.mlb prints "outer", not
"inner.  The sublety (to me anyway) is that we don't "follow" the soft
link by switching to its working directory.  I think this is the
correct decision, because it hides the detail of the underlying file
system (the fact that the file is a soft a link) and views the
filesystem as a map from absolute path to file contents.

On the other hand, suppose we have the following five files.

z.mlb: 
  a/a.mlb
  b/b.mlb
a/a.mlb:
  $(MLTON_ROOT)/basis/basis.mlb
  a.sml
a/a.sml
  print "a\n";
b/b.mlb: --> a/a.mlb  (hard link)
b/b.sml:
  print "b\n";

Then, the program produced by compiling z.mlb prints "a", but does not
print "b".  I think the program should print "a" and then "b", under
the (simple) model of the filesystem as a map from absolute path to
file contents.  I especially think it odd that we have chosen to
expose hard links but not soft links.

I guess what I am saying is that the correct unit of caching for mlb
files in the elaborator is *not* OS.FileSys.file_id, but rather
absolute path.  I don't see any reason to complicate the semantics
with notions from the underlying file system.