2023-11-16 08:56:38 I'm writing a stack in forth, this is my code so far: http://0x0.st/Hvpq.forth 2023-11-16 08:57:12 I'm new to forth so criticism will be welcome. 2023-11-16 11:27:20 I think that all looks pretty reasonable, user51. A slightly different style from my own Forth, but there's nothing particularly wrong with it, and you could have done a lot worse just starting out. 2023-11-16 11:28:12 What tool are you doing this with? 2023-11-16 11:31:30 KipIngram: I was trying to write a forth in forth out of curiousity. 2023-11-16 11:31:45 Which Forth are you using? 2023-11-16 11:31:51 gforth 2023-11-16 11:32:02 Cool. Probably the most common one. 2023-11-16 11:32:25 Since it tends to be there in just about every distro. 2023-11-16 11:39:08 I was also writing simple data structures in forth to get the feel for them. Here's my linked list http://0x0.st/HvfS.forth 2023-11-16 11:40:16 That also looks pretty reasonable to me. I'm not diving deep into it, but it seems tidy and direct. 2023-11-16 11:40:49 Still appreciated :) Not like I can find forth programmers down the street 2023-11-16 11:40:53 That's a good exercise to go through to get the feel for Forth. 2023-11-16 11:41:09 Yeah, we're an endangered species. 2023-11-16 11:42:58 Have you tried a doubly linked list yet? 2023-11-16 11:43:49 That's a someone challenging one - I've done it a few times over the years, with enough time in between to forget. My opinion is that there is a "nice" way to do it, but if you try to do it in any other way it will get all over-complex on you. 2023-11-16 11:44:08 Then when you find that right approach it generates an "Ahhh..>>" feeling. 2023-11-16 11:44:15 Because things just fall nicely into place. 2023-11-16 11:44:33 Ooops; s/>/./ 2023-11-16 11:44:40 Not yet, I'll probably find some time for it eventually 2023-11-16 11:45:49 I wanted to try doing some simple data structures first then tackle some programming challanges, something like advent of code for example 2023-11-16 11:45:59 Another fun little exercise is to write a simple fixed size memory allocator. Wiht fixed size blocks that can be pretty clean. 2023-11-16 11:46:45 : alloc ( -- addr) ... ; and : free ( addr --) ... ; 2023-11-16 11:48:35 That reminds me of an exercise from K&R C, which I planned to tackle with forth at some point 2023-11-16 11:49:15 Have you found Thinking Forth yet? 2023-11-16 11:49:57 I tried Starting and Thinking but they weren't working for me, I ended up looking at the standard's glossary and gforth's word index for help 2023-11-16 11:49:59 https://thinking-forth.sourceforge.net/tf-kindle.pdf 2023-11-16 11:54:09 I never got much into Starting Forth. I like Thinking Forth fOR THE "philosophical" side and one called Forth Fundamentals by Mccabe for the "under the hood" stuff. 2023-11-16 11:54:15 That last one is hard to find, though. 2023-11-16 11:54:41 And it's very old - it's under the hood of quite early Forth systems. 2023-11-16 11:55:40 It was a real eye opener for me, though; I first found Forth back in college, and liked it purely for its RPN nature (I used an HP calculator). 2023-11-16 11:56:00 I had no idea how very elegant Forth is in its implementation until I read FF. 2023-11-16 12:40:04 I'm trying to define a compiling word "IF+" that conditionally executes the following single word (no "THEN" or other delimiter needed). Example usage would be `: try if+ ." positive " ;`  Executing "try" will only do anything if there's a positive integer on the stack.  I'd like the definition to use "if" and "0>".  I'm trying to understand all 2023-11-16 12:40:05 the compile time vs runtime stuff in forth.  The idea for if+ comes from DSSP which is a forth like language from the Soviet Union days.  DSSP decided if+, if-, if0, etc. to shorten code. 2023-11-16 12:42:29 Ok, the typical approach would be for IF+ to be compile-only, and would look something like this: 2023-11-16 12:43:09 : IF+ 0= IF R> CELL + >R THEN ; 2023-11-16 12:43:21 if necessary, just move the return address forward a cell. 2023-11-16 12:44:04 Since you're not targeting some unknown location downstream, you don't need a jump that gets later backpatched. It doesn't even need to be immediate. 2023-11-16 12:45:00 If you tried to run it from the interpreter, it would have unpredictable results. 2023-11-16 12:45:11 If you want it to work in the interpreter you might could do this: 2023-11-16 12:45:32 : IF+ I.e., just skip over the next word of input. 2023-11-16 12:46:10 If you want to try to make it work both ways, then a little more hoop jumping will be required. 2023-11-16 12:48:15 The first one, the word following IF+ that gets skipped does have some limitations. for example, you couldn't do IF+ ." test" or even IF+ 2023-11-16 12:48:30 The skipped thing has to actually be a compiled stand-alone word. 2023-11-16 12:49:20 In the first case it would skip the runtime of ." and try to execute the string. In the second it would skip the (lit) runtime and try to execute the literal value. 2023-11-16 12:59:25 I'm not sure there's a general way of doing that 2023-11-16 12:59:54 Well, you'd have to test for the corner cases and handle them individually. It would suddenly get quite painful. 2023-11-16 13:01:29 I'm ok with it being compile-only and using a compiled single word as the conditionally-run code.  I have it working in gforth when the condition is true, but I'm getting an address alignment exception when the condition is false. 2023-11-16 13:01:33 I think you're right, though, in the sense that there's no "simple" generic way that will work in all cases. 2023-11-16 13:01:54 You must be changing the address by the wrong amount. 2023-11-16 13:02:21 If you know it's a single word with no compile-time behaviour then it should be possible 2023-11-16 13:02:24 My system, for example, is a 64-bit cell size system, but the items in a definition are just 32 bits. So I'd need to add 4 to the address for it to work for me. 2023-11-16 13:03:00 Yes, I see no reason it shouldn't work once you get it tuned right. 2023-11-16 13:03:06 Lemme fire up gforth... 2023-11-16 13:03:53 : if+ postpone 0> postpone if ' compile, postpone then ; immediate 2023-11-16 13:04:21 Looks like this works: 2023-11-16 13:04:30 : skip r> 8 + >r ; 2023-11-16 13:04:40 That's not conditional, but it does skip an instruction. 2023-11-16 13:04:55 So you should be able to put that inside an IF ... THEN 2023-11-16 13:05:15 : alpha 1 2 3 + skip + ; 2023-11-16 13:05:22 alpha leaves 1 5 ono the stack. 2023-11-16 13:05:58 I'm not sure what you're doing with the postpones. 2023-11-16 13:07:01 : if+ 0= if r> 8 + >r then ; ok 2023-11-16 13:07:03 : test 1 2 0 if+ + ; ok 2023-11-16 13:07:05 test ok 2023-11-16 13:07:07 . 2 ok 2023-11-16 13:07:09 . 1 ok 2023-11-16 13:07:48 : test 1 2 1 if+ + ; redefined test ok 2023-11-16 13:07:50 test ok 2023-11-16 13:07:52 . 3 ok 2023-11-16 13:09:08 I haven't done a lot of testing, but GeDaMo's definition with the postpones seems to work 2023-11-16 13:09:25 I often fail to recognize "simple" things I can do with the return stack - a couple of times I'll be struggling with something complex and one of these other jokers here will point out the obvious easy way to do it by tweaking the return stack. 2023-11-16 13:09:34 : test if+ .s .s ; 2023-11-16 13:09:34 see test 2023-11-16 13:10:50 .s must be doing something odd. 2023-11-16 13:11:11 Guest53: it won't work for your example with ." because ." is an immediate word that stores things in the compiled word 2023-11-16 13:11:30 but is that the case for .s as well? 2023-11-16 13:11:36 Thanks for the help!  I'll play around with the definitions Kipingram and GeDaMo gave me 2023-11-16 13:11:37 I'd expect it to work for .s 2023-11-16 13:11:43 No, .s isn't immediate 2023-11-16 13:11:56 Right - so it should be "skippable." 2023-11-16 13:12:40 But it does indeed throw an error, with the same if+ that just worked fine on + 2023-11-16 13:13:36 Good luck Guest53. 2023-11-16 13:30:37 Just read an article that's a new one for me. "Monkey laundering." Apparently that's the practice of capturing wild monkeys and selling them AS "bred in captivity" to research scientists. 2023-11-16 13:30:59 completely screws the resulting scientific results, because there's no control over what the monekeys have and have not been exposed to in the wild. 2023-11-16 13:31:42 China was the main source of such animals, but they shut the exports down because of covid. So prices have skyrocketed. 2023-11-16 13:32:11 Humans show pretty much unlimited ingenuity when there's a buck to be made. 2023-11-16 13:53:59 Reminds me of a certain incident with snakes 2023-11-16 13:54:27 Or maybe it was rats, can't remember 2023-11-16 13:55:16 There was a bounty for snakes so people started breeding the snakes so they could be turned in for money 2023-11-16 13:55:43 https://en.wikipedia.org/wiki/Perverse_incentive 2023-11-16 13:56:02 Ah - exactly the opposite situation, then. 2023-11-16 13:56:32 Sure, why not? Offer to pay for something and people will look for ways to boost the supply. 2023-11-16 14:33:45 Ugh. Had to power cycle one of my test stands. One of its two canisters just completely dropped its pci access to my drives. 2023-11-16 14:33:56 Luckily it was "between tests." 2023-11-16 14:34:10 The next round of tests started off fine after I got it back up. 2023-11-16 14:34:38 The biggest nuisance was that that was the stand I use for tmux windows into my other two stands, so all those had to be re-set up. I really ought to write a script to do that. 2023-11-16 14:36:49 tmux is easily scriptable 2023-11-16 14:41:48 Yeah, I know. Just hasn't quite exceeded my pain threshold yet. 2023-11-16 14:42:10 Generally speaking I wind up power cycling that stand every month and a half / two months. 2023-11-16 14:42:36 I've done some tmux scripting for my pianobarfly set up on my notebook. 2023-11-16 14:43:34 pianobarfly is a console pandora connections; it captures the music into a local directory. 2023-11-16 14:44:18 tmux scripting is annoying :( I made a C program to read a more sensible text file in then output and run the tmux script 2023-11-16 14:44:25 I've got it set up so I can just type "music on" or "music off." Or "music blues," "music srv" (Stevie Ray Vaughn) etc. 2023-11-16 14:44:49 out a shebang at the top pointing to the c program and changes the text file to +x with chmod 2023-11-16 14:45:11 Speaking off, I need to set myself up a George Thorogood channel. 2023-11-16 16:39:03 Tmux was useful for this by letting me set up a background session that I can send commands into - pianobarfly thinks its input is coming from the keyboard. 2023-11-16 18:46:31 any recommendations for a forth OS? 2023-11-16 19:44:07 You might look at collapseos and / or duskos. There's another one out there just called forthos that I ran across some years ago. 2023-11-16 19:44:34 You won't find one with anything like the level of capability you expect from an os like Linux, of course. 2023-11-16 19:48:06 I think one of the things that has changed over the years is that back in the day, when a company made a computer, they shipped it with a BIOS that did a passable job of offering an interface to all of the major features the machine offered, and OS's would build on that. But I doubt you can show me a modern computer that comes out of the box with anything like built in GPU functionality via a BIOS. You 2023-11-16 19:48:08 basically still get the same basic set of functions that was current 20-30 years ago, and all of the new hardware is unsupported until you get a driver loaded. 2023-11-16 19:49:15 So systems like collapseos / duskos wind up having a very yprimitive feel to them. 2023-11-16 19:49:38 AHCI is a bit more complicated than slinging int 10h as need be 2023-11-16 19:50:51 Fair - what I said may not be universally true, but I think it's valid up to a point at least. And maybe the reason wasn't "neglect" - maybe there's just such a diversity of GPUs out there that you can't reasonably cover them in a generic way. 2023-11-16 19:50:58 It may have been unavoidable. 2023-11-16 19:57:16 It also might have been that the motherboard manufacturers didn't have people in house that really knew what to do with a GPU. Here comes this seriously advanced new way of doing things. They could wire it up, but what to DO with it once it was there? Also, those drivers might have exceeded the space typically available to store the BIOS. 2023-11-16 19:57:44 I know at the office they get all bent if some bit of our drive looks like it might cost fifty cents more than they'd expected. 2023-11-16 19:58:15 Driver could get to the customer via the DRIVE - BIOS had to be on the motherboard. 2023-11-16 21:18:18 Just added Fringe to my old show rewatch list. And quite probably Firefly after that. 2023-11-16 22:12:27 KipIngram: thanks.