On 20/10/2015 13:03, Tjark Weber wrote:
On Thu, 2015-10-15 at 15:18 +0100, David Matthews wrote:
I've committed a change to the NestedUse branch which is one possible
solution to this.  The version of "use" in there records the full path
to the parent directory of the file name when a file is "used".  If that
file then contains a nested call to "use" the file is first checked as
previously using the original working directory but if that fails it
looks for the name by appending the parent directory to the name given.
   So in the example above, it would first look for "./first.ML" and only
if that does not exist would it look for "/home/david/mydirectory/first.ML".

With this change,
   use "/home/david/mydirectory/ROOT.ML";
will work as intended *unless* there happens to be a file 'first.ML' in
the current directory. In my view, this is a rather obscure error
condition with great potential for accidental surprises.

The current implementation at least has a simple specification. Also,
it is not at all uncommon to interpret paths relative to the current
working directory; e.g., bash does the same.

What may be missing in SML is a way to determine the name and path of
the file that is being 'used.'

That's a very good idea. I wasn't happy about the solution I'd proposed and having a way of getting the file name is a much better way of doing it. I've modified the NestedUse branch to revert the previous change and added
PolyML.getUseFileName: unit -> string option
This returns the name of the file currently being "used", if there is one.

David
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to