Deutsch English Français Italiano |
<uvqlnp$25k0u$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.unix.programmer,comp.lang.misc,comp.unix.shell Subject: Re: on Perl Date: Thu, 18 Apr 2024 10:30:49 +0200 Organization: A noiseless patient Spider Lines: 42 Message-ID: <uvqlnp$25k0u$2@dont-email.me> References: <uu54la$3su5b$6@dont-email.me> <87edbtz43p.fsf@tudado.org> <0d2cnVzOmbD6f4z7nZ2dnZfqnPudnZ2d@brightview.co.uk> <20240408075547.000061e8@gmail.com> <g52cnWOOwoz_son7nZ2dnZfqnPWdnZ2d@brightview.co.uk> <uvbe3m$2cun7$1@dont-email.me> <Mkidnafag8vlooH7nZ2dnZfqn_idnZ2d@brightview.co.uk> <pan$c8c3e$b0e492b3$c544c27e$d72bff90@invalid.invalid> <uvk8o6$h2pg$3@dont-email.me> <20240415152951.000079ab@gmail.com> <uvkbec$hjeq$1@dont-email.me> <uvlc1f$rgng$1@dont-email.me> <slrnv1smf9.25p4.naddy@lorvorc.mips.inka.de> <uvlp8g$u62e$1@dont-email.me> <87wmowv9fy.fsf@eder.anydns.info> <20240417080523.00005e99@gmail.com> <uvp6gv$1onkq$1@dont-email.me> <20240417121909.000039a3@gmail.com> <uvp996$1p6tk$1@dont-email.me> <20240417133955.00004d23@gmail.com> <20240417211356.581@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 18 Apr 2024 10:30:50 +0200 (CEST) Injection-Info: dont-email.me; posting-host="a0080b8d6f1ecc9cfec5050a64ed5ac7"; logging-data="2281502"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19W9Dyo3Qw6JyvGH01G7QM3gYRVwYtvTiY=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:JSBylXVfe/eaLspLQHo8vHDnvCw= In-Reply-To: <20240417211356.581@kylheku.com> Content-Language: en-GB Bytes: 3984 On 18/04/2024 06:18, Kaz Kylheku wrote: > On 2024-04-17, John Ames <commodorejohn@gmail.com> wrote: >> On Wed, 17 Apr 2024 21:52:06 +0200 >> David Brown <david.brown@hesbynett.no> wrote: >> >>> I think that when finding the definition of a word, Forth just >>> searches back through the stack of definitions until it gets a hit. >>> And if that word definition uses other non-primitive words, it goes >>> backwards from where it currently is, looking only at definitions >>> from before the current word was defined. Is that right? And if so, >>> can you do "forward declarations", and mutual recursion somehow? >> >> That's my understanding, yes; essentially, it's a consequence of the >> fact that definitions are stored as a list of pointers, and re- >> definitions are simply appended to the dictionary without going back >> through the rest of it to update any pointers to the prior definition. >> A strange design choice, but they're consistent with it. > > I don't know at all whether Forth does this or not, but this design > choice allows the list to be restored to a prior state, whereby the > recent definitions are forgotten, and the old ones revealed again, > similarly to shadowed lexicals being revealed again upon the terminaton > of an inner scope. > I suppose it also makes it a great deal easier to have small local functions. Forth programming, as I understand it (I've only done very small tests in Forth - I've never written a "real" program) generally involves breaking code down into very small pieces. So your implementation of "foo" might involve defining words like "get_next", "double", "set_x", or whatever. (In Forth style these would probably be shorter names, and perhaps include symbols.) Your implementation of "bar" might want to re-use these same names but with different definitions. With the list of pointers design of Forth, you can just redefine these "local" words as you need to, and ignore any previous definitions. > It sounds reminiscent of the assoc list representation of the lexical > environment in a rudimentary Lisp interpreter. >