2024-10-24 00:17:20 I haven't done this but I like the idea of a couple temp variables that aren't preserved between words. Seems good for stack juggling 2024-10-24 00:36:05 Registers basically 2024-10-24 00:45:53 Though registers are preserved between words unless you use them for something. I've wondered at times if rdx (the high order half of multiply results) might potentially just be left there to be used by the following word. Maybe you'd have words to push/pop it if you wanted to. 2024-10-24 00:46:39 I haven't really thought through yet whether that would prove usable or not, though. 2024-10-24 03:19:15 do you use the pad area often? I would like if it was in a fixed location 2024-10-24 03:19:59 but I can always make a buffer anyways 2024-10-24 03:29:57 the bot explains it's because forth is usually made for memory constrained environments and making pad a fixed position would not be an efficient use of memory, also it would not be able to grow or shrink as needed, and that the goal is for being temporary 2024-10-24 03:39:31 KipIngram: I want to write a little bit about your token-threading approach in my notebook, pavnotes2, which is public. Should I hold off on that for a while so you can write about it publicly first? 2024-10-24 03:39:47 because I don't think you've fully described it here on the channel, only in /m 2024-10-24 03:40:14 zelgomer: if you want to have a bunch of struct types you can write struct-type-defining words 2024-10-24 03:40:50 I don't think create does> is a template generator. It's a closure generator. 2024-10-24 03:42:20 MrMobius: in standard Forth there's no guarantee that a loop-sys is a single stack item in size (and in all the cases I've looked at it isn't) so using j rather than i is not generally going to work 2024-10-24 03:43:59 xentrac: I think you missed the point 2024-10-24 03:44:17 I do that sometimes. Feel free to elucidate if you want 2024-10-24 03:52:24 no thanks 2024-10-24 04:02:56 no worries 2024-10-24 04:03:02 xentrac: i know that's how it's advertised, but i just can't squint hard enough to see it that way. zarutian described to me once his builds/does which sounded like a legitimate closure to me, because (if i understood it correctly) it was creating anonymous objects at runtime. traditional create is too limited by being a parsing word, it seems no more a closure to me than c's struct keyword 2024-10-24 04:04:32 zelgomer: well, it defines words that run the same code on different data 2024-10-24 04:04:41 but it's true that they aren't *anonymous* closures 2024-10-24 04:05:53 if you prefer you could say that a colon definition using create does> is a *class*, like a Smalltalk class, and the words defined by it are the instances of the class 2024-10-24 04:06:13 of course in Smalltalk instances are allocated on the heap! But that isn't the case in many other languages 2024-10-24 04:06:57 it's sort of a limited class in that it only natively has a single method, like a closure, but you can of course put conditional logic in there to dispatch to different operations 2024-10-24 04:08:20 I realize I have to use uppercase so forth will know I'm serious and it will be easier for it to obey 2024-10-24 04:08:52 it's funny because chatgpt keeps failing until I use caps 2024-10-24 04:11:53 haha 2024-10-24 04:21:10 maybe it's just hard of hearing 2024-10-24 06:00:20 I did not know about ," and I was using place for the same thing 2024-10-24 06:00:26 CREATE MARY ," Mary Brooks" 2024-10-24 06:00:41 (from the forth programmer's handbook) 2024-10-24 06:10:55 That would just print Mary Brooks immediately after the creation of the name MARY. 2024-10-24 06:11:08 no, it's comma quote 2024-10-24 06:11:23 Oh, that's what i get for not having my readers on. Sorry. :-) 2024-10-24 06:12:09 I always forget it exists and tends to be what I want so I end implementing it xd 2024-10-24 06:12:53 a noob will always implement existing features for not knowing they exist, this is why I like to get theory first before practice 2024-10-24 06:42:53 oh hey, I didn't know about ," either 2024-10-24 06:43:14 KipIngram: I want to write a little bit about your token-threading approach in my notebook, pavnotes2, which is public. Should I hold off on that for a while so you can write about it publicly first? 2024-10-24 07:01:30 there are books on forth and ai? 2024-10-24 07:02:03 I know chuck tried to convince ai guys to use forth and he said there was some kind of success, even if most of them disliked it 2024-10-24 07:02:09 I see Designing and Programming Personal Expert Systems 2024-10-24 07:02:29 which seems to show how to make a lisp in forth and then a prolog in that lisp 2024-10-24 07:02:53 asking anna to borrow it 2024-10-24 07:10:55 seems interesting :0 ssays the knowledge base is implemented using forth-83 2024-10-24 07:10:55 cool! 2024-10-24 08:42:42 vms14: That's a nice discovery! 2024-10-24 08:43:42 KipIngram it's an intriguing book, I'm looking forward to see the forth code, starts by explaining ai concepts first 2024-10-24 08:44:48 By all means. 2024-10-24 08:45:07 By all means. with it. 2024-10-24 08:45:56 That's odd. Don't know where that second line came from. 2024-10-24 08:46:07 if you want it you can ask anna, she is quite a nice person 2024-10-24 08:46:36 https://annas-archive.org/search?q=Designing+and+Programming+Personal+Expert+Systems 2024-10-24 08:47:02 it's a scanned pdf from the internet archive 2024-10-24 09:01:53 Ah, you can download it using that link. Thanks, man - grabbed a copy. 2024-10-24 09:02:43 I really enjoyed the computer tech books from that era generally - there were a whole lot of interesting "non same old same old" books if you rummaged around. 2024-10-24 09:03:30 I remember one I got once and still have soemwhere upstairs called "The Cheap Video Cookbook." It outlined a really nifty way to use a cheap microprocessor to build your own video system, and this was way before computer video was so easy to come by as it is not. 2024-10-24 09:03:52 The circuitry tricked the processors normal instruction fetch process into feeding video data to your video output. 2024-10-24 09:04:25 In a certain address range it would feed no-op instructions to the processor, so the address bus just "marched along" and was used to fetch video bytes. 2024-10-24 09:08:05 Ah, I see they talk about "frame representation." That was a common AI method back in the "old school" AI day. 2024-10-24 09:09:07 The field of AI has changed a lot since then - sometimes I think it would be better called (these days) "advanced probabilistic algorithms," since mostly it's about applying probability math like Bayes Theorem and so on to huge mountains of data. 2024-10-24 09:09:37 Back in the day it was oriented more directly toward "ways to make computers think like people." Or trying to, at least. 2024-10-24 09:20:22 BTW, I ran a search there on the archive for "Forth Programming" and got this list: 2024-10-24 09:20:25 https://annas-archive.org/search?index=&page=1&q=Forth+programming&sort= 2024-10-24 09:21:03 Quite a few Forth books there. 2024-10-24 09:21:07 KipIngram: The Cheap Video Cookbook is by Don Lancaster, and is still available on his web site 2024-10-24 09:21:18 he has a lot of other interesting stuff there too 2024-10-24 09:21:21 unfortunately he died last year 2024-10-24 09:21:31 Excellent. I still think that sort of thing is interesting. 2024-10-24 09:21:31 was the "By all means." intended for me? 2024-10-24 09:21:54 Yeah, I think so too 2024-10-24 09:22:06 No, it was aimed at vms14's "It's an interesting book." 2024-10-24 09:23:06 There were just a lot of books pitched at that level of things back in those days. Wandering around in a bookstore was always fun. 2024-10-24 09:23:33 Today's crop of computer books I suppose would still be interesting to someone - just not as interesting to me personally. 2024-10-24 09:24:00 Very little attention seems to be paid these days to the "nuts and bolts" level. 2024-10-24 09:24:31 Computers seem much more just "taken for granted." Black boxes so to speak. 2024-10-24 09:25:38 I wasn't able to sleep tonight - it's 2:25 am here. :- 2024-10-24 09:25:43 :-| 2024-10-24 09:25:52 you'll probably enjoy Bride of Son of Cheap Video, KipIngram: https://laughtonelectronics.com/Arcana/KimKlone/BrideOfSon%20KK%20Lancaster.html 2024-10-24 09:25:56 if you haven't seen it 2024-10-24 09:26:08 I have not - thanks. 2024-10-24 09:26:36 I like the title already. :-) 2024-10-24 09:26:51 KipIngram: I want to write a little bit about your token-threading approach in my notebook, pavnotes2, which is public. Should I hold off on that for a while so you can write about it publicly first? 2024-10-24 09:28:34 No, that's ok. It would be nice if you'd mention me, but I'm happy to share. Chances are it's nothing someone else hasn't done at some point anyway. 2024-10-24 09:30:00 Does that system support comments and public annotations? If so I'll read it when you're done and thoughts. 2024-10-24 09:31:24 "and add" 2024-10-24 09:31:39 Maybe, but not many people read pavnotes2 (in part because it's just a git repository full of Markdown) 2024-10-24 09:35:38 Well, I cloned it and look forward to prowling around. I see your adder circuit there too. 2024-10-24 09:37:13 The circuits stuff is mostly in http://canonical.org/~kragen/sw/leatherdrink.git though 2024-10-24 09:38:05 because I don't want pavnotes2 to get too big, and I expect that some of the electronics notebook stuff is likely to get big 2024-10-24 09:38:06 Also, I see that Lancaster seems to have advanced beyond just streaming bytes to streaming larger words, which I guess would let you do color and so on. 2024-10-24 09:38:36 interesting! I didn't know that! 2024-10-24 09:39:01 I just saw that in the blurb on that page you linked. 2024-10-24 09:40:28 By the way, occasionally some of those old books wind up being worth something. I picked up a little hardback on Yagi antenna design once on a random bookstore walk, and then a couple of years ago I saw that very book for sale online for over $700. 2024-10-24 09:41:24 Just because someone is asking for $700 that doesn't mean they're going to get it :P 2024-10-24 09:41:48 Very true. 2024-10-24 09:42:18 Antenna theory is fun. Neat math. 2024-10-24 09:42:19 Leatherdrink is about a 200-megabyte Git repo, because it includes things like Bostock Observable, the Arduino IDE (including its own copy of the JRE), etc. 2024-10-24 09:42:46 Pavnotes2 is only 38 megs 2024-10-24 09:43:49 I was away, but btw KipIngram if you want to steal books for there there are the fast and the slow ones 2024-10-24 09:44:01 the last of the slow ones does not have a waitlist 2024-10-24 09:44:18 Yeah, I used a slow one. It only made me wait 2 minutes for the link. 2024-10-24 09:44:23 only xd 2024-10-24 09:44:37 I use the last one always which does not have that waitlist 2024-10-24 09:45:23 s/for/from 2024-10-24 09:49:39 also about forth books I have a bookmark with the jupiter ace links 2024-10-24 09:50:01 https://www.jupiter-ace.co.uk/index_forth_books.htmlv 2024-10-24 09:50:55 GeDaMo what was that link for a stack manipulation tool? 2024-10-24 09:50:55 I wasn't able to find it so I will bookmark it 2024-10-24 09:51:23 it was a website telling you the stack operations to use 2024-10-24 09:51:24 http://www.sovietov.com/app/forthwiz.html ? 2024-10-24 09:51:29 ty <3 2024-10-24 09:51:44 saved it now 2024-10-24 21:21:33 vms14: maybe start by never using any stack manipulations except drop, just variables. consider the Lisp (let ((new-number (string-to-number (match-string 1)))) (if (>= new-number counter) (setq counter (1+ new-number)))) 2024-10-24 21:21:52 you can translate that to Forth purely mechanically 2024-10-24 21:22:27 1 match-string string-to-number new-number ! new-number @ counter @ >= if new-number @ 1+ counter ! then 2024-10-24 21:23:21 I'm not going to claim that this is *great* Forth but it is at least *working* Forth and it is trivial to write once you have written the Lisp pseudocode 2024-10-24 21:24:03 you have to have previously declared variable new-number variable counter (and I excerpted this from a loop which initializes counter to 0, which I'm not showing) 2024-10-24 21:25:36 once you have *working* Forth that only use the operand stack in this trivial way, you can refactor it by keeping a variable on the return stack sometimes and a variable on the operand stack sometimes 2024-10-24 21:25:59 which may make it better, or may make it worse 2024-10-24 21:26:55 this will enable you to avoid crying not knowing what you're doing except when you're feeling up for a challenge 2024-10-24 21:27:43 with value instead of variable the mechanical translation would be 1 match-string string-to-number to new-number new-number counter >= if new-number 1+ to counter then 2024-10-24 21:29:51 the stack is there to make it easy to simplify your code, not hard to write it at all 2024-10-24 21:34:31 https://news.ycombinator.com/item?id=40648375 2024-10-24 21:37:37 heh, that's cute 2024-10-24 21:38:04 but I'm not talking about turning Forth into Lisp; I'm talking about a trivial way to get working Forth code if you can already write working Lisp code 2024-10-24 21:38:59 (or working C code, or working Python code, or...) 2024-10-24 21:39:20 Well in that example you can remove the braces when you're done 2024-10-24 21:39:58 Because it has no observable effect, other than enforcing balanced evaluation 2024-10-24 21:40:12 I don't know, what you said just reminded me of that code 2024-10-24 21:40:37 yes, true! 2024-10-24 21:41:07 I wonder if I will use this myself 2024-10-24 21:41:20 it seems like it could be a useful debugging tool 2024-10-24 21:42:00 Sometimes the right way to think about Forth is "if I had an old blinky mainframe and no OS/drivers how would I get up and running" 2024-10-24 21:42:13 yeah 2024-10-24 21:42:26 but I'm not sure that will help vms14 ;-) 2024-10-24 21:42:42 And I think someone using that braces syntax would be on the right track, it's only a few lines of code and helps balance expressions 2024-10-24 21:42:47 It's a good economy 2024-10-24 21:43:32 I wonder if vms14 is interested in playing with an old micro or something, like I did with the ZX Spectrum 2024-10-24 21:43:56 I learned Forth and implemented a Forth mostly because I was interested in the Spectrum, and wanted to push it further 2024-10-24 21:44:16 It got me (more) interested in low-level programming too 2024-10-24 21:44:32 And old 8-bit computers are so *approachable* compared to modern low-level stuff 2024-10-24 21:44:37 maybe, but the thing vms14 is currently running into is the same problem most Forth newcomers run into: because it's always possible to use stack manipulations instead of variables, they think they should, and then they get snarled up in stack modeling 2024-10-24 21:45:09 vms14 needs to look at old Forth code then, which is littered with variables and shortcuts to reduce thinking about the stack 2024-10-24 21:45:39 some, but I think that to start out, you should use way more variables and less stack manipulation than old Forth code usually does 2024-10-24 21:46:04 Forth is a machine with 3 registers, that's how you should think about the stack 2024-10-24 21:46:27 With automatic push/pop at the end if you put more in those 'registers' 2024-10-24 21:46:46 over time impatience will guide you to use the variables less and stack manipulation more, but when starting out the typical failure mode is using *too much* stack manipulation 2024-10-24 21:47:10 Yeah I do agree 2024-10-24 21:47:23 and you end up with a bunch of unreadable tuck rot >r which I think is what's making vms14 and baby Jesus cry 2024-10-24 21:47:27 We're 99% in agreement anyway 2024-10-24 21:48:28 I think that if your code is full of tuck rot then your (very nice) { } will not help much 2024-10-24 21:50:56 I don't really advocate the braces but it's nice knowing you can have almost-lisp in a few lines of code 2024-10-24 21:51:05 yeah 2024-10-24 21:51:05 termbin has erased your code so it's good that Y_Y copied it 2024-10-24 21:51:36 I don't care about posterity but I benefit from them caring lol 2024-10-24 21:51:43 I, hypocrite 2024-10-24 21:51:47 hah 2024-10-24 21:57:14 My advice would be to swallow the stack right up front - you're not going to get used to it until you practice with it. 2024-10-24 21:57:58 But then, the first exposure to programming I ever had in my life was an HP-41CV calculator in college. So I cut my teeth on a data stack right out of the gate. 2024-10-24 21:58:56 Yes but it sounds like vms14 has hit a wall, so it's worth remembering that a lot of the old guard 'make things easy for themselves' 2024-10-24 22:06:29 the HP-41C didn't have >r r> tuck nip 2dup 2drop etc. I think it did have rot but I forget 2024-10-24 22:06:40 so the amount of trouble you could get yourself into was a lot more limited 2024-10-24 22:17:23 Also we're not all the same and we struggle with different things 2024-10-24 22:17:37 yeah, people are very different 2024-10-24 22:17:43 I am not that good at the stack so I just try to be pragmatic about it 2024-10-24 22:18:13 but it seems to be very common these days for people to err on the side of too much stack manipulation when they start Forth 2024-10-24 22:19:27 Starting Forth was written for an audience of BASIC programmers who thought nothing of making a zillion global variables and using them implicitly to pass data between subroutines 2024-10-24 22:19:37 I think 2024-10-24 22:19:44 As was Forth at the time 2024-10-24 22:19:52 Aimed at basic/cobol etc 2024-10-24 22:20:06 IMHO Forth is *practical*, not pure. And it's practical at solving a problem that mostly doesn't exist anymore 2024-10-24 22:20:53 well, it isn't a very mainstream problem anyway 2024-10-24 22:21:09 self-hosted real-time control systems development on small machines 2024-10-24 22:21:45 I would recommend people chasing purity to use Lisp, if you're here to hack and have fun with bits and bytes then you'll do better 2024-10-24 22:22:09 but what I was saying about the variables is that nowadays most programmers know about the problems with making a zillion global variables 2024-10-24 22:22:25 so they tend to shy away from using variables in Forth because they look like global variables 2024-10-24 22:22:52 Well they are global variables 2024-10-24 22:23:16 no; their scope only extends from their declaration to the next declaration of the same name, and in any case is scope within a wordlist or vocabulary 2024-10-24 22:23:47 In Forth you do lots of bad practice in just the right way to achieve your limited problem, rather than worrying about good practice and the general problem 2024-10-24 22:24:03 in BASIC if you try to have two variables named X they are actually the same variable. That doesn't happen in Forth 2024-10-24 22:24:15 True 2024-10-24 22:25:40 similarly in C it's easy to accidentally have global variable name collisions, and those give you a compile error unless you accidentally forgot to declare one of them 2024-10-24 22:27:02 so Forth has ways of solving the problems with global variables, but when you first come to Forth you don't know that 2024-10-24 22:27:15 Well they're more similar to static vars in C 2024-10-24 22:27:35 One of the problems with globals is the lack of reentrancy, which applies to forth 2024-10-24 22:29:35 It's good to know the actual tradeoffs so you can figure out what's worth using, rather than just being allergic to something as useful as a global/static variable 2024-10-24 22:29:56 yes, they're like static vars in C 2024-10-24 22:31:23 the particular cures for the reentrancy problems are explicitly saving the variables on the stack and user variables 2024-10-24 22:31:43 Or avoid using vars for reentrant code 2024-10-24 22:31:48 Which not all code needs to be 2024-10-24 22:32:39 yeah 2024-10-24 22:33:00 I think that if Starting Forth were written today it might talk about this stuff early on 2024-10-24 22:33:19 I think Starting Forth is great honestly, I wouldn't change it much 2024-10-24 22:33:33 It doesn't set the expectations too high IMO 2024-10-24 22:33:40 Thinking Forth however.... 2024-10-24 22:34:19 well, it seems to consistently result in the problem I think vms14 is facing, where you can't figure out how to do anything because you're spending all your mental effort on stack juggling 2024-10-24 22:39:12 I think Starting Forth has variables 2024-10-24 22:40:44 KipIngram convinced me to do an ebook remaster of Starting Forth and hoo boy was that a mistake on my part 2024-10-24 22:41:21 dlowe: how come? 2024-10-24 22:42:03 veltas: yeah, it does have variables! It just doesn't explain why you shouldn't be afraid of them in a way that is sufficiently convincing to a modern audience, I think 2024-10-24 22:43:22 xentrac: it was just a lot more work than I thought it'd be 2024-10-24 22:43:32 all the diagrams had to be redone 2024-10-24 22:43:50 why couldn't you use the existing diagrams? 2024-10-24 22:44:06 it was a pretty nasty scan I was working off of 2024-10-24 22:44:10 oh, I see 2024-10-24 22:44:23 that does sound like a lot of work 2024-10-24 22:45:49 not starting forth, it was "Forth Fundamentals"