Path: utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!imagen!atari!portal!cup.portal.com!Paktor From: Paktor@cup.portal.com Newsgroups: comp.lang.forth Subject: Re: Functional Programming Message-ID: <9714@cup.portal.com> Date: 4 Oct 88 16:42:33 GMT References: <180@kadsma.kadsm> <628@sas.UUCP> Organization: The Portal System (TM) Lines: 40 XPortal-User-Id: 1.1001.4466 In article <1015.3.219.2 Re: Functional Programming> <9/22/88 16:21 bts@sas.UUCP (Brian T. Schellenberger)> writes, referring to functional programming: > In most languages, it is bloody awkward because returning multiple values > is awkward or impossible. In FORTH it's easy--in fact, setting global > variables is what's relatively awkward in FORTH. To the latter assertion, I reply: Au contraire, mon frere; setting global variables in Forth is just as piece-of-cakey as pie. For a ready example, consider the variable, STATE , commonly used in most Forth implementations to distinguish between when the outer interpreter is compiling, and when it is actively interpreting. It is set by : (the colon-word which starts a definition), cleared by ; (the semi-colon word which ends a definition), and used by the word INTERPRET , which is the essence of the outer interpreter... Another handy example is the subtle use of the variable DPL (Decimal-PLace), which is used by NUMBER when interpreting a number that has a decimal point in it, in many Forth implementations. The number is then expanded to a two-cell number-pair, equivalent to the number as if it had no dec- imal point; the value of DPL is then the only thing that indicates the true magnitude of the number as originally entered. If the number had no decimal point, then DPL is set to -1. Other examples of global variables whose values are set within words that per- form other functions can be found both in the elementary Forth implementa- tion and in myriad applications... David ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ === Mister Systems === | "You know the times David L Paktor | you impress me the most | are the times when you don't try; Paktor@cup.Portal.com | when you don't even try." -- Joni M. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~