Deutsch English Français Italiano |
<uvqjlu$257pa$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Lawrence D'Oliveiro <ldo@nz.invalid> Newsgroups: comp.unix.programmer, comp.lang.misc Subject: Re: On Stack-Based Languages (was Re: on Perl) Date: Thu, 18 Apr 2024 07:55:42 -0000 (UTC) Organization: A noiseless patient Spider Lines: 59 Message-ID: <uvqjlu$257pa$1@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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 18 Apr 2024 09:55:42 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e0bbc97582f840a25b6ae44a96748375"; logging-data="2268970"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YqkxxL3EgISE42t/jwUlA" User-Agent: Pan/0.155 (Kherson; fc5a80b8) Cancel-Lock: sha1:PMHcDEjIWv3Ro9m+qYfVfW8k6qg= Bytes: 3196 On Wed, 17 Apr 2024 08:05:23 -0700, John Ames wrote: > *Syntactically* it's very simple, but explicit stack-orientation with > reverse-Polish notation is a *very* different programming paradigm than > practically everything else out there ... The only really tricky part of stack-based programming is keeping track of what’s on the stack. I did some messing about with a reboot of PostScript which tried to add some niceties, like stack guards and lexical binding. Here’s an example of the sort of thing I was able to get working (“ddef” and “dstore” define and assign to dynamically-bound variables, while “ldef” and “lstore” correspondingly work on lexically-bound ones): /Count 99 ddef /metatry { % provides context for nonlocals dup /Name exch ldef /Count 0 ldef { % actual proc /Count dup lload 1 add lstore /Count dup dload 1 add dstore Name = (local Count = ) print /Count lload = (global Count = ) print /Count dload = (whichever Count = ) print Count = } } ddef /try1 metatry ddef /try2 metatry ddef try1 try2 try1 try2 Output: try1 local Count = 1 global Count = 100 whichever Count = 1 try2 local Count = 1 global Count = 101 whichever Count = 1 try1 local Count = 2 global Count = 102 whichever Count = 2 try2 local Count = 2 global Count = 103 whichever Count = 2