| Deutsch English Français Italiano |
|
<mcj94rF8ri9U1@mid.individual.net> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: minforth <minforth@gmx.net> Newsgroups: comp.lang.forth Subject: Re: Parsing timestamps? Date: Wed, 2 Jul 2025 01:26:18 +0200 Lines: 52 Message-ID: <mcj94rF8ri9U1@mid.individual.net> References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org> <a004d0f4acf945e054db77d86a4544fc@www.novabbs.com> <nnd$0d7645ea$11a210a3@2cd6ffa4d9a3008a> <4a4c38c99d22d97314ed5750af38430d@www.novabbs.com> <765bd244e1368b5691f18c748102470e8de1a30d@i2pn2.org> <nnd$0deda869$2559e613@c251414cde7edbe7> <103ilab$225q0$1@paganini.bofh.team> <cda70ea80eb98069a3060f95503d0853@www.novabbs.com> <2025Jun29.171314@mips.complang.tuwien.ac.at> <96f3b6d94af924cf1468a2cced37966d@www.novabbs.com> <d5ff6c298dff84dabc278ac1a28087d55126645e@i2pn2.org> <0cd5e9d5959101c1efa68a2d6d630e23@www.novabbs.com> <069f09501a3c6fcade18fdf83925d835514b42cc@i2pn2.org> <44b5f13fd49d8ddbd572ae583379d124@www.novabbs.com> <21113c70c36a86f0fd4c74c8d11d0947528ba70f@i2pn2.org> <20baae7dd561db60967a5937d2b59d9a@www.novabbs.com> <0db20ddf954106bbca40d9e83630033f108b9a8e@i2pn2.org> <87bjq5yn8i.fsf@nightsong.com> <nnd$6da712e9$10ba1712@89d620b4a5dddb34> <8734bfzrdl.fsf@nightsong.com> <20250701234705.000044ce@tin.it> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 5re+P0TlzFo+w5S2Z/tGpwxOvonHl96oX6YXsEcTN8KHh+j+Yh Cancel-Lock: sha1:2AKoBfiIHBOhShirbKIkt6G07NQ= sha256:WQhs9lweDXUSxf7Pc0pDOCmGJVy5lPJRQhT3jQIH/YM= User-Agent: Mozilla Thunderbird In-Reply-To: <20250701234705.000044ce@tin.it> Am 01.07.2025 um 23:47 schrieb peter: > On Tue, 01 Jul 2025 11:40:38 -0700 > Paul Rubin <no.email@nospam.invalid> wrote: > >> Hans Bezemer <the.beez.speaks@gmail.com> writes: >>>>> But such would indicate a deficiency in Forth. Do C programmers >>>>> reach a point at which they can't go forward? ... >>> Another great argument to leave Forth and embrace C! Why painfully >>> create kludge to cram into a language that was clearly not created >>> for that when you have a language available that was actually >>> DESIGNED with those requirements in mind?! >> >> I'm not sure what you're getting at here, though I see the sarcasm. >> >> Is the kludge locals? They don't seem that kludgy to me. >> Implementing them in Forth is straightforward and lots of people have >> done it. >> >> Finally, a fancy enough Forth compiler can do the same things that a C >> compiler does. Those compilers are difficult to write, but they exist >> (VFX, lxf, etc.). I don't know if locals make writing the compiler >> more difficult. But the user shouldn't have to care. > > The code generator in lxf has no knowledge of what a local is. > locals are conceptually placed on the return stack. lxf is as smart > about the return stack as the data stack. that is why it can produce > very efficient code for simple examples like 3DUP. The actual > implementation of local in the interpreter is just a few lines of code. > The difference with locals will be seen when you have a boundary block, > IF statement, a call etc that require a known state of the stacks. > The real problem for me with locals is that their scope is to the end > of the definition. With the stack you end the scope of an item with a > drop and extend it with a dup, very elegant! > A multipass compiler can of course find the scope of each local but at > the cost of more complexity. > > In lxf64 I have introduced a local stack with the same capabilities as > the data and return stack. I am not sure yet if this is better. > > The nice thing is that I now have >ls ls> and ls@. Compared with the > return stack this also works across words. One word can put stuff on > the localstack and another retrieve it. This is sometimes very useful. In a sense, such locals become global. I am not sure if this opens the way inadvertently for hard-to-detect bugs. One rarely discussed property of locals is that they offer data encapsulation (or have scope in C terminology). Only one useful application comes to my mind: sharing locals between quotation and its parent function, i.e. for creating closures. But who needs thema anyway?