Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!MITCH.ENG.SUN.COM!wmb From: wmb@MITCH.ENG.SUN.COM Newsgroups: comp.lang.forth Subject: NUMBER and block files and ANS Forth Message-ID: <9007020308.AA02478@ucbvax.Berkeley.EDU> Date: 30 Jun 90 01:53:50 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: wmb%MITCH.ENG.SUN.COM@SCFVM.GSFC.NASA.GOV Organization: The Internet Lines: 57 FS> (It was more amusing, though, when I thought you objected to it being FS> one giant file at the same time Robert objected to it NOT being one FS> giant file.) This is the kind of problem that the ANS Forth committee has to deal with every issue. In this particular case, ANS Forth gives you both choices, in a particularly nifty way: BLK SOURCE-FILE Input source ------------------------------------ nonzero 0 Block from "global block space", i.e. entire disk farm is one giant array of blocks nonzero nonzero Block from file whose descriptor is contained in SOURCE-FILE 0 0 Keyboard 0 nonzero Text file whose descriptor is contained in SOURCE-FILE FS> ... discussion about how to implement NUMBER? so a program can parse FS> without risking an ABORT ... If you have CATCH and THROW , the obvious implementation of ABORT is "-1 THROW". This turns out to be an excellently useful thing, because then a program has the option of handling any ABORT condition that arises. In this case, NUMBER? is trivially defined as: : NUMBER? ( a -- d flag ) ['] NUMBER CATCH IF ( x ) DROP 0 0 FALSE ( 0 0 false ) ELSE ( d ) TRUE ( d true ) THEN ( d flag ) ; An even better approach is to let the application take care of CATCH'ing the call to NUMBER, because that gives the application the flexibility of choosing the level at which to handle the error (which might be several levels up from the actual call to NUMBER ). This can eliminate several levels of "passing flags back up". CATCH and THROW: Try it, you'll like it. Use it in your kernel, and your kernel may get smaller (mine did). One other observation: Implementing ABORT with CATCH and THROW eliminates the one "unavoidable" forward reference in the Forth kernel (the ABORT - QUIT - INTERPRET - NUMBER - ABORT cycle). A kernel with CATCH and THROW can be compiled entirely incrementally. Mitch