In article <jt2c4j$c4$
1...@online.de>, Bernd Paysan <
bernd....@gmx.de> wrote:
>Make ENVIRONMENT? obsolecent
>============================
>
>20120704 Initial proposal
>
>Problem
>=======
>
>The Forth-94 standard specified an environmental query system, which
>allows to query the system for capabilities and some constants, like PAD
>and HOLD buffer sizes and maximum integers (which can be calculated
>using standard words). This interface was not common practice when it
>was proposed, and it didn't attract followers afterwards. Almost 20
>years later, it's time to revisit this word, and look at current
>practice.
>
I introduced WANT some time ago, when Anton Ertl complained that
my REQUIRE didn't follow conventions.
It didn't catch on, but I wonder how good it would be to replace
ENVIRONMENT?
This could be a proposal, but I'm not crazy enough to propose
in earnest something that has not enough current practice.
I can testify though that it works very well in ciforth
to load fine grained (block sized) extensions.
What I like is the very short description and the very short
reference implementation.
""""""""""""""""""""""""""""""""""""""""""""""""""""
WANT "name1".."name#" ...
Documents that the program uses the words following :
name1 ... name# ...
RATIONALE:
WANT can be used in several ways:
1. merely as documentation
2. as an indication for a system to make the words
available, by loading files or blocks
3. to give a warning up front for all missing words at
the same time, instead of one by one
4. as an indication for a system to warn that the words
are present, but not standard conforming
5. names can be restricted to standard word sets, (except
CORE) or to words present in controlled libraries.
Or it can be used to make words available specific
to a particular system, which amounts to documenting
that it will not run except on that particular system.
It is recommended to precede WANT with
a specification where the words are from.
For example
( FILE ) WANT OPEN-FILE READ-FILE CLOSE-FILE
( FSL: bignum ) WANT BNUMBER B* B+
( VFX: carnal ) WANT sleezy-bot
( This program only runs on gforth ) WANT gforth
A minimalist implementation is:
: WANT POSTPONE \ ;
Libraries mentioned in a lot of portable programs would
slowly gain an official status.
""""""""""""""""""""""""""""""""""""""""""""""""""""
Notes:
- The important thing to realize is that only actual words
are allowed.
- If it is used to load automatically, failing loads are not allowed
to break off compilation (!), that would violate the behaviour
of WANT.
- actual words can be dummy words. A dummy word
like EXCEPTION-PRESENT could mean that all words of
exception are present. (It is created after the whole facility
loaded successfully.)
WANT CORE-EXT-PRESENT
would replace
S" CORE-EXT" ENVIRONMENT?
0= [IF] REQUIRE /oops/what/goes/here [THEN]
On a system where the core extensions are not available
the latter probably gives
ENVIRONMENT? Not a word or number
[IF] Not a word or number
REQUIRE Not a word or number
(interspersed with edits to include facilities.)
- in practice WANT F* FSIN will go a long way to guarantee that
the whole floating point is present
- failing loads must not break off, but it is certainly
allowed to give a warning like
"
WARNING can't make F+ available because [
/usr/lib/ciforth/float.fs ERROR #-2 no such file or directory.
]
"
Groetjes Albert