> This is the third RfD on this topic. The second one was in July
> 2007. You find the updated text further down.
I have two issues outstanding:
1) F" is not a fully reusable tool,
2) Name explosion, e.g. why not FS" for file in a search path.
The first issue is that applications often extract file names
from places other than source code or the command line. They
should be able to use the tools. At present this proposal is
limited to the time frame of compilation from files.
a) What happens if no file is being compiled?
b) is there an implicit idea of a base directory?
c) What happens to the implicit base directory when the file
closes?
The second issue concerns opening the door to (say) FS" which
specifies that the file is included from a search path. However,
many of these actions are better performed by the consumer.
I'm trying to look at this from the perspective of the
application programmer (AP). APs use the shortest and simplest
approach. For example, they don't use INCLUDED unless they have
to - many of them don't know it exists.
Relative to the current file directory is only one special case.
Other common ones are relative to the application source tree,
relative to the Forth tool tree, or relative to some particular
tool's tree.
Rather than use INCLUDE-NAME-ABS as the primitive, I would
suggest
TransFileName \ caddr1 len1 mode -- caddr2 len2
where mode is an opaque type that defines how the name is to be
translated. Note that mode can also be passed in a system-
dependent manner. Let's define mode=0 or some such as the normal
unprocessed state, such that caddr2/len2=caddr1/len1. We can
also state that mode is reset by all consumers, even if they
THROW.
Now we can define a set of triggers:
-FMODE \ -- ; what we have now
RELATIVE \ -- ; relative to current file
SERACHPATH \ -- ; relative to the search path
...
With a suitable primitive, we can then define a relative
include:
variable Fmode \ -- addr ; holds consumption mode
: FINCLUDED \ caddr len --
Fmode @ TransFileName ['] included catch
0 Fmode ! \ or NORMAL
throw
;
Now we have tools that can be used by applications in a layering
to be defined by the implementer, and we do not have to define
multiple new words for every search extension. All we have to do
is to define the time frame of extension triggers and the words
that set them.
Short cuts such as xINCLUDE now reduce to trivial definitions.
If you build this into INCLUDE itself, you get
RELATIVE INCLUDE foo.bar
or you can define
: RINCLUDE RELATIVE INCLUDE ;
: SINCLUDE SEARCHPATH INCLUDE ;
IMHO it is really important to consider application programmers.
They are the people who use what toolmakers produce. Remember
also that Forth is an interactive language and we should make
our primary tools available at run time.
Stephen
--
Stephen Pelc, stephen@...
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads