Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!ames!haven!boingo.med.jhu.edu!aplcen!aplcomm.jhuapl.edu!john From: john@aplcomm.jhuapl.edu (John Hayes) Newsgroups: comp.lang.forth Subject: Re: BASIS 14... comments Message-ID: <1990Dec4.100730.10629@aplcen.apl.jhu.edu> Date: 4 Dec 90 10:07:30 GMT References: <9011302145.AA09747@ucbvax.Berkeley.EDU> Sender: news@aplcen.apl.jhu.edu (USENET News System) Reply-To: john@aplcomm.jhuapl.edu (John Hayes) Organization: JHU/APL, Laurel, MD Lines: 41 Mitch Bradley writes: > By the way, now that we have COMPILE, (compile-comma), the words > POSTPONE , [COMPILE] , and COMPILE are all unnecessary, as the desired > effects may be achieved with ['] foo EXECUTE and ['] foo COMPILE, This is true but the results of such an implementation would be inefficient on native code systems. The problem is that a postfix COMPILE, (compile-comma) operator has less information available to it than a prefix POSTPONE operator. I offer two examples: 1) Some native code systems have a compiler vocabulary with compile-time versions of many primitives (e.g. DUP). This compile time DUP, compiles top-of-stack duplication code and may apply peephole optimization. An ordinary version of DUP appears in the user visible vocabulary; ['] returns this 'ordinary' DUP. ['] DUP COMPILE, compiles a subroutine call to DUP; the COMPILE, (compile-comma) does not have enough information to inline the DUP. 2) Some native code systems store information in a definition's header to determine whether that definition should be inlined or or called as a subroutine. The compiler's internal equivalent of COMPILE, (compile-comma) given the execution address of a definition, computes the address of the data in the header. A user accessible COMPILE, (compile-comma) may not assume that the execution address belongs to a definition with a header; START: allows the construction of headerless code. Therefore, COMPILE, (compile-comma), must always compile a subroutine call. Again, COMPILE, (compile-comma) does not have the necessary information. I assert that POSTPONE is the fundamental operator. POSTPONE is used for more often than COMPILE, (compile-comma) and [COMPILE] in programs. Therefore, it should be as efficient as possible. By being prefix, it has the opportunity to use the name following it in the input stream to extract the necessary information. COMPILE, and [COMPILE] can be defined: : COMPILE, POSTPONE LITERAL POSTPONE EXECUTE ; : [COMPILE] ' COMPILE, ; IMMEDIATE John R. Hayes john@aplcomm.jhuapl.edu Applied Physics Laboratory Johns Hopkins University Brought to you by Super Global Mega Corp .com