From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie)
Newsgroups: comp.lang.forth
Subject: Environmental Queries
Date: 22 Aug 92 13:27:32 GMT
Organization: EIEI-U

Category 10,  Topic 33
Message 11        Fri Aug 21, 1992
B.RODRIGUEZ2 [Brad]          at 22:52 EDT
 
                 ANSI X3J14 FORTH TECHNICAL PROPOSAL
                     (X3J14 dpANS-3, March 1992)

TITLE:  ENVIRONMENT? should take text from input stream

SECTION:  6.1.1345 ENVIRONMENT?

SUMMARY:  ENVIRONMENT? should take its argument from the input
     stream, and not from the stack.  A new name is suggested.

PROPOSAL:  Change section 6.1.1345 to the following:

     6.1.1345 ENVIRONMENTAL                            CORE

          ( "name" -- false | value true )

          Parse name delimited by a space, ignoring leading
          delimiters.  name should be a keyword from 3.1.4
          Environmental Queries or the optional word sets to be
          checked for correspondence with an attribute of the
          present environment.  If the system treats the
          attribute as unknown, the returned flag is false;
          otherwise, the flag is true and the value returned is
          of the type specified in the table for the attribute
          queried.

     Note: the name ENVIRONMENTAL is proposed to avoid confusion
     with the existing word ENVIRONMENT?, and for better
     readability.  The Technical Committee may change the name of
     this word without altering the intent of this proposal.

RELATED PROPOSALS:  'S" should be interpretive in CORE'

DISCUSSION:  ENVIRONMENT? is flawed in that it requires a string
     argument.  This is unusual, and is not common Forth practice
     for a word of this nature; but more significantly, there is
     no truly portable means to obtain such a string argument
     while compiling a program.  (See the related proposal for a
     discussion of this problem.)

     A more common Forth practice is to pick up a string argument
     from the input stream.  This would also serve to improve
     readability of the code.  For example, the phrase
          ENVIRONMENTAL MAX-N
     is more readable and less cryptic than
          S" MAX-N" ENVIRONMENT?

     By parsing its argument from the input stream, ENVIRONMENTAL
     eliminates the need for an interpretive S", which (I have
     been told) presents a problem to some Forth systems.

     Also, this definition of ENVIRONMENTAL is readily applicable
     to Forth cross-compilers.

     ENVIRONMENTAL can be readily defined in terms of the previ-
     ous dpANS word:
          : ENVIRONMENTAL   BL WORD COUNT ENVIRONMENT? ;
     Indeed, it has been pointed out informally that this is how
     the Technical Committee expects ENVIRONMENT? to be used.  If
     this is so, then it is the word ENVIRONMENTAL which should
     be standardized.

     Note: if the related proposal, 'S" should be interpretive in
     CORE' is adopted, this proposal is not withdrawn.  Whatever
     the disposition of S", I believe that ENVIRONMENTAL is
     preferable to ENVIRONMENT?.

     Objections.

     It has been suggested that, for utmost flexibility, an
     environmental query word is required which accepts an argu-
     ment on the stack rather than in the input stream.  There
     are three responses to this:

     a) this is a purely hypothetical need: no example of where
     this would be useful has been offered.

     b) the Technical Committee has not seen fit to do this for
     such fundamental words as CREATE, so one may presume that
     this kind of flexibility is not considered an essential part
     of dpANS Forth.

     c) I have no objection to retaining the word ENVIRONMENT? as
     an auxiliary word, as long as the word ENVIRONMENTAL remains
     in the Core word set.  I would suggest that ENVIRONMENT? be
     placed in the Core Extensions or other optional word set.

     I maintain that ENVIRONMENTAL is the word that must be in
     the Core word set.  The fact that it can be defined in terms
     of ENVIRONMENT? is untrue for cross-compilers, a realm in
     which environmental queries will be particularly important.
     By specifying ENVIRONMENTAL as the Standard word, we define
     an environmental query mechanism that can be used in all
     environments.

-----
This message came from GEnie via willett.  You *cannot* reply to the author
using e-mail.  Please post a follow-up article, or use any instructions
the author may have included (USMail addresses, telephone #, etc.).
Report problems to: dwp@willett.pgh.pa.us