Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!pt.cs.cmu.edu!dsl.pitt.edu!pitt!willett!ForthNet From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: Input Stream Message-ID: <1612.UUL1.3#5129@willett.pgh.pa.us> Date: 27 Aug 90 03:30:50 GMT Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 90 Category 3, Topic 45 Message 1 Sun Aug 26, 1990 R.BERKEY [Robert] at 19:30 PDT Subject: Re: Factoring of CREATE Doug Phillips writes <24 Aug 90, in comp.lang.forth>: > > From where we stand today, the QUOTE-TO solution as given by > > Robert Berkey is probably the best way out of the jam. QUOTE-TO > > allows you pass a stack string to an existing defining word, > > e.g., > > " FOOBAR" ' CREATE QUOTE-TO > Boy, that sounds really familiar. Was it written up anywhere (FD, > etc?)? QUOTE-TO.SCR is a Forth-83 Standard Program available on GEnie and BCFB. It was written in part as an exercise in writing a Standard Program, as well as for the perennial question concerning the code that passes s to defining words. QUOTE-TO.SCR includes the word "> ("quote-to"), which is a one-word syntax, and there is also a two-word syntax such as Mitch has shown. The word "> is state-smart: " NEW-NAME" "> CREATE or : "CREATE ( \ addr len -- ) "> CREATE ; " NEW-NAME" "CREATE The alternate two-word syntax is easier to implement. QUOTE-TO.SCR shows it with the word . Interpretively: " NEW-NAME" ' CREATE In a colon definition: : "CREATE ( \ addr len -- ) ['] CREATE ; " NEW-NAME" "CREATE > [The obvious question: Can QUOTE-TO be done in > BASIS/dpANS-Forth?] (or QUOTE-TO ) should be easier in BASIS than Forth-83 as the string need not be moved into TIB . This eliminates the three string moves needed in Forth-83, i.e., (1) saving TIB , (2) loading TIB , and (3) restoring TIB . However, it's not clear on how to set >IN in BASIS. "Input stream" remains on the burning issues list. : ( addr len token -- ) BLK @ >R >IN @ >R #TIB @ >R SOURCE-FILE @ >R \ save-it ROT ROT ( token addr len) 0 BLK ! \ prepare BLK 0 SOURCE-FILE ! \ prepare SOURCE-FILE TIB ROT - DUP >IN ! ( token len tib-addr) \ prepare >IN + #TIB ! ( token) \ prepare #TIB EXECUTE \ do-it! R> SOURCE-FILE ! R> #TIB ! R> >IN ! R> BLK ! \ restore-it ; (This is here so that Mitch or anyone else can tell me how to fix or improve it.) > [The obvious question: Can QUOTE-TO be done in > BASIS/dpANS-Forth?] Actual translation of QUOTE-TO.SCR from Forth-83 to BASIS has been left as an exercise to the Net in Puzzles and Problems. I'm sure that QUOTE-TO.SCR is non-compliant with BASIS, but just how much makes it a puzzle for me too. Robert ----- This message came from GEnie via willett through a semi-automated process. Report problems to: uunet!willett!dwp or dwp@willett.pgh.pa.us