Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.forth Subject: Re: defer this not Date: Thu, 07 Jul 2016 13:32:12 -0700 Organization: A noiseless patient Spider Lines: 24 Message-ID: <87bn29faur.fsf@jester.gateway.pace.com> References: <6f902b6d-b141-4a32-9848-3959eb135610@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="010a62d875807b9be55d34aa1bf0a902"; logging-data="2407"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mJob0Tr5Lcocr4DW4GoC7" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:KlkGLXfsMNhmYSEVAh6Z0a16TQU= sha1:bisTE+WvJEa3dCDr+BydoGS3DuI= Xref: csiph.com comp.lang.forth:48924 Alex Dowad writes: >> A programmer should have the freedom to arrange his word definitions >> in whatever order he/she wishes (within one compilation unit)... > With some programming languages, your code is executed as it is > read. With others.... Forth and Lisp are firmly in the first category, > as are all the "scripting languages". Of course, the second type also > has its place. But trying to force Forth into the latter paradigm is a > poor fit. The difference isn't whether the whole file is read before execution starts. Rather, it's that Forth traditionally uses early binding while Lisp and scripting languages typically use late binding. So (defun cube (x) (* x (square x))) (defun square (x) (* x x)) (print (cube 3)) prints 27, because when cube is compiled, it allocates a cell for the previously unseen symbol "square", then when square is compiled it puts code into that cell, and then when cube is called, it runs the code that is now in the "square" cell. The Forth approach would throw an error in the definition of cube, because square was not already defined. I believe late-binding Forths have also been implemented.