2024-09-03 00:08:50 is it doing any more than adjusting the stack pointer for the reservation and keeping track of where that begins? 2024-09-03 00:11:45 hm? 2024-09-03 00:12:03 oh, with the dictionaries? yes, PostScript dictionaries are heap-allocated objects 2024-09-03 00:12:37 ok 2024-09-03 00:21:42 so i guess >> is popping elements off the stack (or insert optimization here) directly into the dictionary somewhere on the heap, until the stack pointer is equal to current-stack-mark? 2024-09-03 00:22:54 yes, exactly 2024-09-03 00:23:03 and similarly with ] 2024-09-03 00:23:56 if you *did* want to try implementing the operand stack as a rope as I suggested above for roll, you could avoid that copying ;) 2024-09-03 00:33:57 too complicated for a beginner like me :) 2024-09-03 02:03:27 i have a spare bit in my avr forth tokens 2024-09-03 02:06:53 hmm on second thoughts 2024-09-03 02:07:11 trying to use the bit for anything interesting increases NEXT from 5 to 7 cycles 2024-09-03 02:08:38 not sure it's worth it 2024-09-03 02:14:54 what bitfields have you got already? 2024-09-03 02:15:03 token number 2024-09-03 02:15:08 which only takes 7 bits 2024-09-03 02:15:32 because i ran the numbers and i'm not gonna fit everything within 2k of the jump table 2024-09-03 02:15:43 which means i need to use long jumps, which take two words 2024-09-03 02:16:05 so now either i shift the token left one bit before jumping 2024-09-03 02:16:24 how do you determine if a word is immediate? 2024-09-03 02:16:41 or i sack off one bit 2024-09-03 02:16:49 immedacy only matters at compile time 2024-09-03 02:16:50 ie. not runtime 2024-09-03 02:16:57 ok 2024-09-03 02:17:44 also i'll probably be compiling on my laptop and just sending tokens across to the avr 2024-09-03 02:17:56 saves implementing the compiler frontend on the avr 2024-09-03 11:17:38 in forth, can i leave an outer loop? 2024-09-03 11:37:34 rendar: No 2024-09-03 11:38:01 You can leave multiple times, exit, do some kind of forth-specific jump/goto 2024-09-03 11:38:09 etc 2024-09-03 11:38:22 I would use EXIT there usually 2024-09-03 11:38:36 For which you need two UNLOOP's 2024-09-03 11:38:56 i se 2024-09-03 11:38:59 i see* 2024-09-03 18:25:14 Good factoring practice would probably lead to nested loops being in different words - I would avoid having nested loops in a single definition. 2024-09-03 18:25:54 Generally I write my definitions so each one is on a single line. These days I run 40-50 characters per def. I start to stress if one gets longer than 50 and look for ways to factor. 2024-09-03 18:27:13 Of course this changes where outer loop indices are on the return stack, since you've slapped a return address on their. Makes having J, K, etc. words difficult. 2024-09-03 18:27:49 You could maybe have a separate stack for loop variables, but that brings its own nuisances to RAM layout and so on. 2024-09-03 18:29:00 I guess if I wrote a word that was going to need a loop index from its callers I'd put that index on the data stack as a word parameter before calling it. 2024-09-03 18:29:29 So I'd never actually need J, K, etc. - they'd be I when I fetched them to pass to the lower words. 2024-09-03 18:33:22 You don't really want the inner word to depend on how you've written the outer word anyway. 2024-09-03 18:35:19 I was thinking last night about how to make decompilation trivial, and one of the things I came up with was having the only control flow be a conditional return, with an implicit infinite loop in every word 2024-09-03 18:35:31 that way you never need jump offsets 2024-09-03 18:36:06 in the usual case where you don't want your word to be a loop, you just put a return instruction before its end, the way you normally would 2024-09-03 18:36:29 (with a condition that's always true) 2024-09-03 18:36:56 when you do want it to loop, you just leave that final return instruction off, or (in the repeat until case) make its condition sometimes false 2024-09-03 18:37:23 that would make it actually impossible to have more than one loop in the same word 2024-09-03 18:37:54 and it would remove the difficulty with j, k, etc. 2024-09-03 18:38:29 however 'You don't really want the inner word to depend on how you've written the outer word' would go out the window 2024-09-03 19:02:46 One of the things I did out of curiosity was make a word that takes an xt and wraps it in a loop. Not exactly but here's the code: http://0x0.st/XwmG.forth 2024-09-03 19:03:11 xentrac: I use conditional returns almost exclusively for control flow. 2024-09-03 19:03:21 That and conditional "loop back to start of word." 2024-09-03 19:03:37 I don't have the usual control words (IF THEN, etc.) in my system at all. 2024-09-03 19:03:51 I still don't know what it's called, or if it's useful. But it was fun. 2024-09-03 19:03:51 You're right about it easing decompilation. 2024-09-03 19:03:59 recurse-if is all you need 2024-09-03 19:04:23 Probably, but a full family of conditional returns is quite useful. 2024-09-03 19:04:35 I can also conditionally "double return." Return to caller's caller. 2024-09-03 19:04:52 0=; 0=;; etc. 2024-09-03 19:05:29 half-walrus and full-walrus operators! 2024-09-03 19:17:37 :-) 2024-09-03 19:18:36 I did the whole matrix as primitives; all the different conditionals, with and without an implicit 0 operand, signed and unsigned, etc. Wrote a Python script to generate the assembly code for it all. It just creates an include file I pull into my nasm source. 2024-09-03 19:19:11 It occurred to me later I should have had that script do the unconditional and "leave a flag on the stack" versions too, but I didn't think of that so they are still manual. 2024-09-03 19:19:19 Next time. 2024-09-03 19:20:06 I thought up a naming convention so I don't have to remember a bunch of arbitrary names. 2024-09-03 19:33:22 Can't help, I'm out of cool ideas. As far as the parsing words from yesterday go, I'm prepared to pay the parsequences. 2024-09-03 19:40:05 very parsimonious of you 2024-09-03 19:41:46 Here's one: any fun or interesting ways to take advantage of how the dictionary defines words? Specifically, the linked list structure of it, which allows us to redefine a word and execute the old definition in that new word. Simple examples might be : name ( code here ) name ; or : name name ( code here ) ; 2024-09-03 20:39:10 user51_: that wouldn't work in my systems (where I expose names immediately on creation), so I'd have to do something like http://forth.works/share/p3MocxHSYp.txt to refer to the old definition 2024-09-03 20:41:13 Mine either - as soon as the header for the word is created in my dictionary, that is what that word will do. So a call to foo from a new foo will just recurse the new foo. 2024-09-03 20:42:24 personally i'd prefer : FOO FOO ; to call the old foo 2024-09-03 20:42:28 Actually I could play vocabulary games to get around that, now that I think about it. Word searches do not search CURRENT in my system. 2024-09-03 20:42:32 because i basically never recurse 2024-09-03 20:42:54 Normally CURRENT is also in the CONTEXT list, so it doesnt matter, but I could not have it there, and then the newly defined foo would not be found. 2024-09-03 20:43:24 Well, I don't realy recurse either - I tend to look at it all as looping in an explicit way. 2024-09-03 20:44:21 And, you can have it however you like it - that's the beauty of rolling your own. :-) 2024-09-03 20:54:24 KipIngram: interesting, what's your experience been like? 2024-09-03 21:35:18 Not sure what you mean. I found that adding those ocnditional returns had a strong effect on how I coded. I'm totally convinced my definitions got shorter and I started to enjoy it all more. Not trying to say it's the "best" way, but it seems like a good way for me. 2024-09-03 21:35:57 It feels like when I look back at code I wrote that way some long period earlier it's easier for me to remember what the heck I was doing. 2024-09-03 21:36:10 But someone else might look at it and want to vomit - who knows. 2024-09-03 21:42:31 yeah, that's what I mean 2024-09-03 21:42:50 what have you liked, what have you disliked, what do the results look like? 2024-09-03 21:46:23 I'm not sure that shorter definitions are better in general; I think that Forth's effective requirement to keep your definitions short is a major thing that biases Forth toward flexibility and away from predictability on the flexibility/predictability tradeoff 2024-09-03 22:38:21 https://cbarrete.com/carmack.html describes one contrary point of view 2024-09-03 22:38:57 > The fly-by-wire flight software for the Saab Gripen (a lightweight fighter) went a step further. It disallowed both subroutine calls and backward branches, except for the one at the bottom of the main loop. Control flow went forward only. Sometimes one piece of code had to leave a note for a later piece telling it what to do, but this worked out well for testing: all data was allocated statically, and 2024-09-03 22:39:03 monitoring those variables gave a clear picture of most everything the software was doing. The software did only the bare essentials, and of course, they were serious about thorough ground testing. 2024-09-03 22:39:07 > No bug has ever been found in the "released for flight" versions of that code. 2024-09-03 22:39:49 My scripting language for my MUD worked that way. 2024-09-03 22:40:23 I had to make sure that builders couldn't hang the whole system with a scripting mistake 2024-09-03 22:40:58 oh interesting! TinyTIM tried to do that but failed 2024-09-03 22:41:18 (because it had potentially recursive subroutines) 2024-09-03 22:42:04 you could make two objects loop with each other but it would still have to yield control between interactions 2024-09-03 22:42:18 BPF and Bitcoin Script are the only things I've heard about before that worked that way 2024-09-03 22:42:43 did you have subroutines and/or loops? 2024-09-03 22:43:41 no, potentially looping things were handled by internals, and there wasn't really any need for subroutines 2024-09-03 22:44:40 so you would have to send a message to another object, and that would just go into the event queue? 2024-09-03 22:44:56 Right 2024-09-03 22:45:10 that seems like sort of a natural transaction boundary too 2024-09-03 22:45:57 There's 3987 fibers running now, on top of the other things the system does 2024-09-03 22:47:20 oh, so you don't just have a global event loop, but 3987 separate stacks? 2024-09-03 22:47:31 it is so interesting to join a channel about a language alien to me, and try to imagine what is being discussed 2024-09-03 22:48:18 sadly, not about forth atm, though I've been toying with porting it. 2024-09-03 22:48:22 I suspect the language dlowe is talking about is alien to all of us ;) 2024-09-03 22:48:35 there was a MUD that used a Forth, I think. MUF was the language? 2024-09-03 22:48:49 unfortunately, writing the engine is truly the easy part 2024-09-03 22:49:08 well, that might depend on what the engine does ;) 2024-09-03 22:49:09 getting volunteer authors on board is a lot harder 2024-09-03 22:49:10 "MUF (short for Multi-User Forth) is a Forth-based programming language used on TinyMUCK MUCK servers and their descendants, including Fuzzball MUCK, ProtoMUCK and GlowMUCK" 2024-09-03 22:50:22 it looks like this - https://dlowe.net/tmp/prog.txt 2024-09-03 22:50:45 heh, written by Piaw Na, author of "An Engineer's Guide to Silicon Valley Startups" 2024-09-03 22:51:14 wow, that looks very nice and simple and easy to learn 2024-09-03 22:51:23 what are the asterisks? 2024-09-03 22:51:49 the constraints were - must be easy to edit on a line editor, must resemble mud commands, and must not cause the mud to halt 2024-09-03 22:52:04 aahh, that makes sense 2024-09-03 22:52:12 lines without asterisks are interpreted by the mud as commands 2024-09-03 22:52:51 they could temporarily turn off all output so creatures could do things behind the scenes without needing an explicit interface 2024-09-03 22:53:47 Implementation: https://github.com/TempusMUD/Tempuscode/blob/main/src/search/prog.c 2024-09-03 22:53:56 are all the objects in the same room sort of connected to a single event bus, like in Kafka? 2024-09-03 22:54:02 or RabbitMQ 2024-09-03 22:54:09 no, it was a lot more ad-hoc than that 2024-09-03 22:54:10 or uh IRC 2024-09-03 22:54:33 there were attempts to migrate it over to one but it's a lot of overhead 2024-09-03 22:55:04 still running, almost 30 years now 2024-09-03 22:55:21 not many players tho :p 2024-09-03 22:56:39 yeah, WoW, Minecraft, and Roblox have stolen a generations of MUD players ;) 2024-09-03 22:57:19 I've recently abandoned Planetside 2 for Roblox :O 2024-09-03 22:57:31 not familiar 2024-09-03 23:00:04 It's fine. muds weren't for everyone even in their heyday 2024-09-03 23:00:37 xentrac: I've become very fond of the short definition approach, and now I cringe a little if I see a Forth definition spill off down a page, or if it's indented like C, etc. 2024-09-03 23:01:24 KipIngram: I'm curious to hear what you think about Carmack's 2000 line main loop in that link 2024-09-03 23:08:05 game dev is its own thing 2024-09-03 23:08:30 software engineering is programming while keeping the future in mind 2024-09-03 23:08:44 but typically for games that are released, there's no future to keep in mind 2024-09-03 23:09:16 that reminds me there is some kind of forth for the gameboy 2024-09-03 23:09:32 http://gbforth.org/ 2024-09-03 23:09:35 never tried it 2024-09-03 23:11:28 and an example https://github.com/tkers/fortboy 2024-09-03 23:35:08 dlowe: What's funny is creatives find it easy to get creatives onboard, and not devs 2024-09-03 23:36:18 Planetside 2 is great 2024-09-03 23:36:29 Not that I have had time to play in years