Re: How does Require deal with multiple files of the same name in




Jos van de Ven wrote:
"George Hubert" wrote:

Jos van de Ven wrote:
"George Hubert" wrote:

I'm coming round to the following. The is file loaded test should return
true;
1) If an absolute path is specified and that file is loaded.
2) If a relative path is specified, there is at least one file in the
search path that matches and any of the matching files are loaded
(possibly issuing a warning if more than one file is in the path).
3) If a relative path is specified, there are no files in the search
path that match but there is a file loaded that would match (possibly
issuing a warning that the file isn't in the current path).

So far agreed.

4) If a relative path is specified, there is at least one file in the
search path that matches but none are loaded though there is a file
that matches in the search order and a system variable is set to a
never reload if any matching file is present mode.

Perhaps the same behaviour should take place when an absolute path is specified.
When a system variable is set to a never reload, require does not load any
file at all.


Surely if an absolute path is specified the program wants that specific
file loaded, even if another file of the same name is loaded? I can't
think of any program where that applies (every program I know uses
NEEDS or REQUIRE with a relative path anyway; they assume the files are
going to be either the current dircetory (or a sub-directory) or the
Forth system directories), so it wouldn't really bother me either way.
The main problem is that older versions of Win32Forth (such as V4.2)
only stored the file name so wouldn't re-load a file if any file of
that name were loaded.

Is there a case in which a file will be re-loaded using the 4 conditions above?


No! If the sytem variable is set to not reload a warning could be
issued, perhaps stating which file (i.e. the full path) is already
loaded. If the variable is set to re-load then the first matching file
in the search is loaded; in that case no specific information is
presented although the file could do .( Loading Foo.... ) to inform the
user (a good idea in general anyway).

Jos

George Hubert

.



Relevant Pages

  • Re: How does Require deal with multiple files of the same name in
    ... If a relative path is specified, there is at least one file in the ... search path that matches but none are loaded though there is a file ... Perhaps the same behaviour should take place when an absolute path is specified. ... only stored the file name so wouldn't re-load a file if any file of ...
    (comp.lang.forth)
  • Re: How does Require deal with multiple files of the same name in
    ... If a relative path is specified, there is at least one file in the ... search path that matches but none are loaded though there is a file ... Perhaps the same behaviour should take place when an absolute path is specified. ... When a system variable is set to a never reload, ...
    (comp.lang.forth)
  • Re: lock on filename for XmlDocument.Save?
    ... sometimes absolute path and sometimes relative path. ... XmlDocument.Save with a filename attempts to open the file in Create mode for Writing with only Read sharing. ... if you don't really care that the second simultaneous Save is going to destroy the data from the first Save, you could just do a lock the XmlDocument.Save function call, which will enforce only one save at a time, or you could do a bit more complicated logic if you do care that you are overwriting an existing file, which will happen once the first Savecompletes. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: absolute path to relative path conversion
    ... you give as you are effectively just after the filename: ... You could walk from you absolute path to the root of your drive and then ... walk down the path to your file, building the relative path as you go along. ... > Sorry for being so vague Rob ...
    (microsoft.public.dotnet.languages.csharp)