2024-12-21 00:03:23 well, to start with, it uses a lot of variables in order to match the BASIC program it is a port of, so it's not exactly idiomatic 2024-12-21 00:04:12 Chuck Moore says using lots of variables is idiomatic, though F83 for example isn't written that way 2024-12-21 00:04:15 I think trying to avoid using variables is one of the biggest pitfalls for newcomers to Forth 2024-12-21 00:04:53 because although it's *possible* to make your code hard to maintain by using variables too much, it's almost universal to make your code hard to maintain by not using them enough 2024-12-21 00:05:05 lol 2024-12-21 00:05:11 noted 2024-12-21 00:05:28 and ending up with, like, >r >r rot over r> r@ and whatnot 2024-12-21 00:05:53 *head spins* 2024-12-21 00:06:02 heh 2024-12-21 00:06:51 you always *can* avoid using local variables by using stack manipulations instead (r> and >r move your Turing machine left and right on the tape) but that doesn't mean you should 2024-12-21 00:16:36 I hate to use variables for stuff that doesn't have "longevity." 2024-12-21 00:43:49 but everytime you use r> for value storage you wanted a variable 2024-12-21 00:45:48 I don't know, I think it's reasonable to keep one thing on the return stack 2024-12-21 00:46:30 it's not too confusing. "oh yeah, the file descriptor goes on the return stack throughout this word." 2024-12-21 00:47:07 at the end you need "something" sometimes 2024-12-21 00:47:11 the thing about variables is you have to name them 2024-12-21 00:47:20 but a local variable is what you would use I guess 2024-12-21 00:47:31 one of the main advantages of forth is you dont need to name things anywhere near as often 2024-12-21 00:47:43 in my not so forth I have "temporary" variables that will get destroyed when the colon word ends execution 2024-12-21 00:48:04 ive been working on a local variable implementation for mine 2024-12-21 00:48:10 they're just to bind elements from the stack 2024-12-21 00:48:20 in mine they go on the return stack 2024-12-21 00:49:53 the problem is with them you will never learn to use the stack xd 2024-12-21 00:50:50 but no need to anyways 2024-12-21 00:52:19 performance is a joke since it's written in perl xd 2024-12-21 00:52:24 0 1 1000000 range '+ iterate 2024-12-21 00:52:32 this takes 6-4 seconds 2024-12-21 00:53:04 which is to create a list of the ten million numbers and then iterate that list summing them 2024-12-21 00:53:30 for a variable with a small scope you can often use names like n t s end sp and the like 2024-12-21 00:53:43 but the day I learn to make a transpiler I will have no such problem 2024-12-21 00:54:01 I've been reading Appel's textbook on compiler design 2024-12-21 00:54:32 not "Compiling With Continuations", but "Modern compiler implementation in ML", which kind of covers a lot more ground 2024-12-21 00:55:02 I haven't finished it yet, nor written any compilers using what it teaches, but I'm still pretty confident in recommending it 2024-12-21 00:55:18 it's on libgen.li if that's legal in your country 2024-12-21 18:03:09 I see it here: 2024-12-21 18:03:11 https://github.com/AntonPing/Modern-Compiler-Implementation-In-ML/blob/master/Modern_Compiler_Implementation_in_ML.pdf 2024-12-21 18:03:59 Unless that's another book of the same exact title - the author doesn't match what xentrac listed. 2024-12-21 18:04:21 Oh wait - yes it does. 2024-12-21 18:04:26 I was looking at the wrong place. 2024-12-21 19:01:52 it also wouldn't be inconceivable for me to get the author wrong, though in this case I was reasonably sure because of what I imagined was a certain sense of self-satisfaction when he cited his own earlier work 2024-12-21 19:02:32 ML is a really nice language for this kind of thing 2024-12-21 19:02:53 his home page for the book is https://www.cs.princeton.edu/~appel/modern/ml/ 2024-12-21 19:08:20 gvwilson's review https://web.archive.org/web/19971210161349/http://www.ercb.com/ddj/1997/ddj.9709.html said, "For a start, this is one of the first compiler texts I have seen that presents, at an undergraduate level, developments from the mid-1980s onward. There are chapters on lexing, parsing, and abstract syntax, but there are also chapters on basic blocks and traces, instruction selection algorithms, 2024-12-21 19:08:26 liveness analysis, and register allocation (a topic that wasn't even in the index of the text I used 15 years ago). This breakdown of topics is a good reflection of where a compiler writer's time actually goes. Most books, on the other hand, tend to concentrate on what we already understand (57 flavors of parsing) rather than what we actually do." 2024-12-21 19:18:42 That is a really worthwhile commentary. 2024-12-21 21:06:47 I would expect the register allocation and instruction selection bits to be particularly interesting. 2024-12-21 21:15:20 https://www.mattkeeter.com/blog/2022-10-04-ssra/ 2024-12-21 21:15:28 "The Solid-State Register Allocator" 2024-12-21 22:43:32 What I've usually found, though, is that in Forth there are enough system level functions I want to use registers for that I don't really have any particularly large number or registers left over that require "short term allocations." 2024-12-21 22:43:58 By the time I'm done putting in all the features I want, I've mostly used them up. 2024-12-21 22:44:23 The only down side of that, in my opinion, is that it increase context switching work.