Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucsd!sdcc6!ir230 From: ir230@sdcc6.ucsd.edu (john wavrik) Newsgroups: comp.lang.forth Subject: Domain of Forth Keywords: ANSI Questions , Control Constructs Message-ID: <12354@sdcc6.ucsd.edu> Date: 21 Aug 90 06:25:36 GMT Organization: University of California, San Diego Lines: 100 ANSI QUESTIONS I. Machine Readible BASIS I waited for a machine readible BASIS12 only to find that I would need Microsoft Word to read it. Some postings suggest a misunderstanding of the rationale for a machine readible copy of the BASIS. It is NOT to save money. Downloading from GEnie, even if successful, probably costs more than $10. It IS to allow people to study the document and to comment upon it. It would have been nice to have some exchanges on the network with quotes from the document. It would also be nice to pick the document apart and put it into a database. A lot of the information we all have about the workings of the ANSI team is hearsay and opinion -- a document in a useful form would be a good tool to focus the debate. Suggestion: The ANSI team make available a packet consisting of the printed BASIS document and a diskette with the document in machine-readible form (preferably including a plain ASCII text glossary file). THIS SHOULD BE AVAILABLE IN A TIMELY FASHION SO THAT USERS HAVE AMPLE TIME TO PREPARE SUBMISSIONS TO THE ANSI TEAM. In a recent posting I gave an implementation of an algorithm about permutations. Three things arose that I would like to ask someone on the ANSI team to address. II. Deferred Execution Will the proposed ANSI standard have a portable mechanism for deferred execution (like the F83 words DEFER and IS) III. Recursion and return stack size When implementing a recursive algorithm it often becomes necessary to increase the size of the return stack. Will there be a portable way to do this? Along the same lines: will there be words analogous to RP0, SP0, RP@, SP@? IV. Language Constructs A major feature of Forth is the user's ability to create control constructs. An extremely simple one appeared in the permutation algorithm If( c1 e1 c2 e2 ... ck ek )If The ci are non-destructive conditionals (they add a flag to the top of the existing stack). This construct finds the first ci which tests TRUE, executes the corresponding ei and exits the construct. Each ei is responsible for cleaning the stack -- the last conditional is often TRUE to clean the stack if all other conditions fail. A. My original implementation of this has it compile to handler | addr of end | c1 | e1 | ... ck | ek Where the handler employs a loop to execute the ci until it finds one which is TRUE. My impression is that the proposed ANSI Standards will not provide a portable means for accessing the IP (and that code which involves handlers cannot be portable). Is this correct? B. In this case, the construct is easily built up from IF .. ELSE .. THEN. The following definition just uses these: : )IF ; : IF( 0 >R \ count the number of IFs used BEGIN ' DUP ['] )IF <> WHILE , [COMPILE] IF ' , [COMPILE] ELSE R> 1+ >R REPEAT DROP R> 0 DO [COMPILE] THEN LOOP ; IMMEDIATE How would this be rewritten to comply with the proposed ANSI Standards? (I'd like to emphasize that this is a very elementary and useful construct -- BUT I AM NOT ASKING FOR IT TO BE INCLUDED IN THE STANDARD -- only (1) whether the Standard will permit the user to make simple constructs like this and (2) how much alteration of existing code is required) V. Power of Proposed Standard Far more significant than the controversy over certain proposed words are the circulating rumors that some members of the ANSI Team do not expect it to be possible to write significant programs using only proposed words and programming practices. Is the ANSI team willing to provide clarification, at this point, as to whether or not a purpose of the proposed Standard is to allow users to write significant programs portably? John J Wavrik jjwavrik@ucsd.edu Dept of Math C-012 Univ of Calif - San Diego La Jolla, CA 92093