Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!ubc-cs!alberta!ncc!idacom!rob From: rob@idacom.uucp (Rob Chapman) Newsgroups: comp.lang.forth Subject: Re: Domain of Forth Message-ID: <1990Aug30.193536.26356@idacom.uucp> Date: 30 Aug 90 19:35:36 GMT Organization: IDACOM, a division of Hewlett-Packard Lines: 55 > John J Wavrik > II. Deferred Execution > Will the proposed ANSI standard have a portable mechanism for > deferred execution (like the F83 words DEFER and IS) I posted a possible word BIND ( tic-token \ tic-token -- ) which would allow the same functionality of DEFER and IS. It would allow the choice of early binding as well. > IV. Language Constructs > 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've always found [COMPILE] things confusing especially when COMPILE is included as well. Rewriting the definition for IF( to make it ANS Forthable: : IF( 0 >R \ count the number of IFs used BEGIN ' DUP ['] )IF <> WHILE COMPILE-TOKEN ['] IF EXECUTE ' COMPILE-TOKEN ['] ELSE EXECUTE R> 1+ >R REPEAT DROP R> 0 DO ['] THEN EXECUTE LOOP ; IMMEDIATE When I'm explaining the delayed execution of immediate words to people, I find it clearer by using: ' something EXECUTE (we use the state smart definition of ' from figForth) It is complementary to: ' something COMPILE As an example, this might be the definition of OF for a case extension: : OF ( ? ) ' OVER COMPILE ' = COMPILE ' IF EXECUTE ' DROP COMPILE ; IMMEDIATE Note: Our COMPILE is the equivelant to the ANS Forth COMPILE-TOKEN which takes a tic-token off the stack and compiles a call to it. ( If I miss the mark on quoting ANS Forth, its because its from memory). Its a pity that COMPILE was initially defined as a look-ahead-at-runtime construct. Rob