Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.forth Subject: Re: dynamic scoping in Forth in one line of code Date: Fri, 28 Aug 2026 18:12:48 -0700 Organization: A noiseless patient Spider Lines: 8 Message-ID: <87y0dplofj.fsf@nightsong.com> References: <87bjamc5xh.fsf@debian> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 29 Aug 2026 01:12:49 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3001068"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IMcFY7jpHx89y3SFhFExX"; posting-host="6dfd35adcf802a6459ae63f5abc2ac7a" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cancel-Lock: sha1:CGBcz5oTGuXzm+5MqzWmwWVnZf4= sha1:CBK0jNjrzUU8GCXIkI1QRapOnI4= sha256:Vy5TySAMhR7oJcvedKeVYLxa1gBRdjfirBOlCZvvrqM= sha1:ukr+jy0qZ7ZBJWNa1K+QVAjNfGA= sha256:nHMkngTFA9R8UYvNvYOVy4LgT1LX6X9K8zZwUP+nE5A= Xref: csiph.com comp.lang.forth:135469 Kragen Javier Sitaker writes: > A couple of years ago, I noticed that it’s possible to implement > Lisp-style dynamic scoping in standard Forth in one line of code: > > : (let!) dup @ over swap 2r> rot >r rot >r >r >r ! ; : let! (let!) 2r> ! ; You need to still restore the old value when the function exits by exception or THROW. So you have to use something like CATCH.