2023-12-01 00:01:09 KipIngram, review the gforth stack-frame words. 2023-12-01 00:02:06 What are they called? 2023-12-01 00:02:50 stack frame words ;-) 2023-12-01 00:03:15 The main reason I introduced the first sort of stack frame was to allow me to index into the stack in a nicely controlled way. But it wound up having a fringe benefit even if I don't need to do that - it guarantees getting the stack clean, even if I have multiple paths that leave differeing amounts of stuff on the stack. 2023-12-01 00:04:02 I don't get any easy response when I Google gforth stack frame words. 2023-12-01 00:04:21 The second type was to let me "leap out" of a deep nesting of calls. 2023-12-01 00:05:15 Like in FIND - I'm way down in a triply nested loop when I achieve 'success' and find the word I'm looking for. {| and |} give me a way to jump all the way back out in one go, which makes it so those words in the middle don't have to know how to deal with "success." 2023-12-01 00:05:39 They're just written as though the search will fail every time. 2023-12-01 00:06:07 KipIngram, https://dl.acm.org/doi/pdf/10.1145/378911.378917 best link so far 2023-12-01 00:06:26 Thanks. 2023-12-01 00:07:07 https://dl.forth.com:8443/jfar/vol3/no1/article3.pdf 2023-12-01 00:07:20 That looks slightly similar to mine, except I save the old frame pointer on the return stack rather than the data stack. 2023-12-01 00:08:03 I guess some things there are only so many ways to do. 2023-12-01 00:08:29 yeah, yer working in one or another space - even if you allocate a THRID space (like float) 2023-12-01 00:08:37 third, two 2023-12-01 00:08:50 I originally tried to do without a frame pointer and just index off of the stack pointer, but that gets confusing because it's constantly changing, which makes the index of the various items change too. 2023-12-01 00:09:18 Much easier to keep up with what's going on if you have a fixed reference frame. 2023-12-01 00:09:22 I am fine with forth swap-shit 75% or more of the time, but the stackframe stuff is sometimes about the ONLY path to sanity 2023-12-01 00:10:20 My worst situation was QUERY. EXPECT already had several items on the stack that I needed to get at more or less at the same time, and QUERY made it worse by adding in a command history list to keep up with too. 2023-12-01 00:10:31 (and yeah, I dislike dribbling variables around when a frame makes more sense) 2023-12-01 00:10:40 hah! yeah 2023-12-01 00:10:46 At some points in there there were six things to juggle around, and the normal noodling words just don't know what to do with that. 2023-12-01 00:11:05 right, that's when ARG1 ARG2... make sense 2023-12-01 00:11:45 We had a talk here one day about turning the whole system inside out, with a GUI style event loop, and that would altogether change how the text input of the system worked - it did seem like that would clean things up quite a lot. 2023-12-01 00:11:50 KipIngram, I suspect the best approach, btw, is a small stackframe voc, too. Keeps it the hell out of the way, otherwise 2023-12-01 00:11:59 Because in the context of a GUI, text fields on screen need to have some global state associated with them. 2023-12-01 00:12:07 So the amount of stuff to keep on stack was reduced. 2023-12-01 00:12:16 But I haven't actually done a system that way yet. 2023-12-01 00:12:37 sounds moot: what happens when you "redirect" source or sink? 2023-12-01 00:12:58 Don't know - haven't done that yet either. But it's part of what I want in this next one. 2023-12-01 00:13:05 ok 2023-12-01 00:13:29 well, then yer in need of handles/streams for i/o. - rather than raw bit/byte 2023-12-01 00:13:43 Yes - streams/devices. 2023-12-01 00:13:54 stdin/stdout/stderr. 2023-12-01 00:14:37 "The system" will just process stdin to stdout, but that might wind up coming from / going to all kinds of places. 2023-12-01 00:14:45 Mind you, C (and nix) always pissed me off: certain things you NEED to do are only available on the handle/FILE* you ain't using. 2023-12-01 00:15:24 I never really accepoted that idiocy: since the underlying code HAD to be the same 2023-12-01 00:16:18 (and then there are the linux raw syscalls that "are not portable" - and remain necessary. 2023-12-01 00:16:31 We were just talking about that (the "everything is a file" thing in Linux) earlier today. 2023-12-01 00:17:07 Yeah, try porting syscalls between MacOS and Linux. That's kind of a nightmare. 2023-12-01 00:17:40 Especially if you're not using C, because you need those magic numbers in the C .h files. 2023-12-01 00:29:54 I always felt that the integer ID (handle) was great for portability, but then they hid shit inside and in-support-of FILE* - and it just pissed me off.. Almost nothing user-side needs to see inside a FILE struct, so just write the goddamned operators and be done, sheesh 2023-12-01 00:30:39 ..andother linux syscall/irritation was the "char ready" or "bytes available" shit. 2023-12-01 00:31:21 Yeah, I think seek, read, write mostly covers your bases. 2023-12-01 00:38:03 Well, and open/close. 2023-12-01 00:46:08 KipIngram, you need MORE - check those syscalls for the ready/available stuff, for the crap we need to convert handle to FILE* and FILE* to handle to do.. It's just damned silly. 2023-12-01 01:00:02 Well, one thing I want is to be able to start a disk operation in a non-blocking way, and then have a follow-on call I make later that will block if the data still isn't ready. That way I at least have a chance to do other work while the disk is cranking. 2023-12-01 03:44:02 Man, don't y'all ever shut up? 2023-12-01 03:56:14 no 2023-12-01 04:08:11 oh, wow - something other than join/leave was listed.. opps. Missed it. 2023-12-01 04:11:49 PoppaVic: feel free to monologue 2023-12-01 04:11:59 someone may comment after they wake up 2023-12-01 04:12:54 Nah.. That's as bad as Standup.. hell, next someone will do the Vagina Moaninglog and then everyone will head-explode ala' Kingsmen 2023-12-01 04:13:25 ..Back to back to Falling Skies 2023-12-01 04:55:53 Kingsman was good. 2023-12-01 04:56:14 I went in not expecting too much and was pleasantly surprised. 2023-12-01 04:56:29 Manners. Maketh. The man. :-) 2023-12-01 04:59:09 yup.. and 'splodin' heads ;-P 2023-12-01 04:59:55 ..in fruity-rainbow colors ;-) 2023-12-01 05:03:44 f redcoats 2023-12-01 13:35:40 I'm quite happy using FILE* 2023-12-01 13:36:22 I wish they added a type for file handles in C to make them a bit more type-safe, like HANDLE* or something, doesn't need to actually point at anything would just improve type safety 2023-12-01 13:37:23 There was a convention at one point in C for opaque structs to be typedef'd as an ALLCAPS name, hence FILE, the point of FILE is you can't see in the struct and it might not even be a struct at all, it's just a handle in a sense itself 2023-12-01 13:37:33 I quite like this method of encapsulation in C and use it often 2023-12-01 13:38:05 Makes ABI's more stable too 2023-12-01 13:38:48 I'm not 100% sure what PoppaVic was trying to say about this but just opining 2023-12-01 13:40:32 I wish the standard exposed the virtualisation features of FILE that are present in many standard libraries. Most standard libraries allow giving custom callbacks for read/write/seek and this is how they e.g. implement snprintf() 2023-12-01 13:41:41 Instead to achieve this portably you need to add another level of abstraction on top yourself 2023-12-01 14:35:00 Oh, I hadn't realized that all-caps in a type implied "opaque." That's interesting to know. 2023-12-01 14:36:51 Yeah, I like that callback idea. That's the kind of thing I was trying to get above re: BLOCK; instead of returning an address, maybe it returns an XT and then you later call that to get the address. That one might block or might not - depending on whether the data's resident yet or not. 2023-12-01 14:37:19 In that case, though, there's an overt block number, so it could also be implemented as just a pair of words. 2023-12-01 14:37:32 You'd give the block # to both of them. 2023-12-01 15:00:27 KipIngram: The all-caps for opaque thing is very old now, most people don't do that anymore. You still see it in some places. 2023-12-01 15:02:57 I complained to microsoft that they had listed tmpfile() as 'unsafe' and deprecated it, even though there's nothing unsafe about it in principle and it's a C standard library function. 2023-12-01 15:03:07 They're saying you should use s_tmpfile() instead in their docs 2023-12-01 15:03:29 But s_tmpfile() isn't more safe in its interface, it's just *consistent* with the safer IO functions appendix 2023-12-01 15:04:01 And by saying tmpfile() is unsafe and deprecated they're just creating unnecessary work for people 2023-12-01 15:04:05 But no dice 2023-12-01 15:04:55 The implementation MS have is actually not very good, but that's a defect in their implementation. The solution is to improve the implementation, not mark a standard library function as unsafe 2023-12-01 15:05:19 It's hard enough writing portable C code already, don't need MS deprecating standard functions that aren't deprecated in the standard 2023-12-01 15:07:53 A loooong time ago MS apparently exposed which file was created by tmpfile(), and it's always in C:\ so has permissions problems, and has a relatively short set of possible names and suffers from ocassional collisions which it just reports as an error. 2023-12-01 15:08:08 And this is now probably necessary for backwards compaibility on some sad programs 2023-12-01 15:08:20 But I say just fix it in the new redist... 2023-12-01 15:08:50 And people think Forth is hard! 2023-12-01 15:44:01 KipIngram: just noticed that the 16 instructions you mentioned yesterday didn't include any comparision operators, how are you planning on implementing them? 2023-12-01 15:51:32 Conditional return and conditional recursion words. 2023-12-01 15:51:58 In my current system I have a massive matrix of them; I generated the assembly source for those with a python script. 2023-12-01 15:52:34 All six comparison cases, < <= = != >= >, then with and without default 0 argument, and also where appropriate signed and unsigned cases. 2023-12-01 15:52:55 And finally I have versions of all of them that consume all arguments, and versions that will leave the deepest argument present for re-use. 2023-12-01 15:53:05 That winds up being over a hundred primitives. :-| 2023-12-01 15:53:33 I have an easy to remember convention for their names, so no real "memorization" was required to use them. 2023-12-01 15:54:50 In addition to building those around "return" and "recurse," i can also do "double return," which discards a return address from the return stack before conditionally returning. 2023-12-01 15:55:07 So yeah - I have those bases well and truly covered. 2023-12-01 15:55:33 I do everything that way - I don't even have IF THEN, BEGIN AGAIN, DO LOOP, etc. 2023-12-01 15:56:36 I won't have instruction space for so many in this new system, so I'll have to give thought to exactly how I want to bundle things. 2023-12-01 15:56:57 Or, rather, which ones to make primitive instructions and which ones to implement as higher level words. 2023-12-01 16:02:03 Just as an example, you might see .u<=;; which would do an unsigned <= comparison of the top two items and if satisfied do a double return. because of the . prefix it would drop only the top argument and would keep the second one. 2023-12-01 16:02:22 That . prefix isn't a "compiler" thing; it's not supported algorithmically. It's purely a naming convention. 2023-12-01 16:03:30 I use a fair variety of them - at some point I should probably scan all the source I've written and identify which ones I hardly ever use. 2023-12-01 16:03:38 : +< ( n1+ n2+ -- n1 ; \ compare two positive numbers 2023-12-01 16:03:50 The most commonly used one, I think, is 0=; or 0!=; 2023-12-01 16:03:54 This word is part of how I would compare numbers without comparison operators if I had to do that 2023-12-01 16:04:24 That's nifty. 2023-12-01 16:04:30 The next step is compare top bit of two numbers, and then if they're equal compare the lower bits with that 2023-12-01 16:04:53 I leave the definition of U< and < to reader as an exercise 2023-12-01 16:05:33 :-) 2023-12-01 16:06:00 Oh look it's time for my first advent of code 2023-12-01 16:06:09 I am going to need to give thought to EXACTLY what to do this next go round. I can't have the luxurious "all primitive" approach I took before. 2023-12-01 16:06:30 That's up to you 2023-12-01 16:14:45 Lovely, another boring parsing exercise to trip up the forthers on day 1 2023-12-01 16:17:32 Well, all I meant is that this time I can't have an arbitrary number of lowest level operations. I guess i'll still have "primitives" written directly in vm instructions, and can have as many of those as I like. But the vm instruction set itself will be "limited." 2023-12-01 16:18:16 In a code threaded system, though, there's a bit less distinction between "primitive" and "definition." A primitive is just a word that makes no calls. 2023-12-01 16:18:41 And a definition one that only makes calls. In code threading we can get anywhere in between too, so it's a spectrum now. 2023-12-01 16:20:32 zx spectrum is back, baby! 2023-12-01 16:21:11 Oh, it's up for sale again? 2023-12-01 16:21:37 The main computer from the past I'm a little sorry I missed out on was the Amiga. 2023-12-01 16:21:58 well you said it was a spectrum... 2023-12-01 16:22:06 OH. 2023-12-01 16:22:14 Ha - I didn't catch on those were related. 2023-12-01 16:22:17 Gotcha. 2023-12-01 16:33:01 Parsing thing is re advent of code 2023-12-01 16:36:30 Ah that makes sense, is there any reason for doing it that way though? 2023-12-01 16:37:47 YEah, the Amiga was really supposed to be a radical improvement.. That disappeared. 2023-12-01 16:45:23 hello-operator: What's that regarding? 2023-12-01 16:56:22 In regards to the conditional returns replacing the normal primitives 2023-12-01 16:57:51 KipIngram: ^ 2023-12-01 16:58:25 Yeah, my bad, should've prefixed my comment :/ 2023-12-01 16:58:47 No harm done 2023-12-01 17:04:02 hello-operator: Well, it is just "a way" of doing it - I've kept it because I like it. I'm convinced that it's caused me to writer shorter, easier (for me at least) to understand definitions. 2023-12-01 17:04:35 It's easier for me to look back at old code and recover what's going on, etc. That could be entirely a personal ideosyncracy of mine, though. 2023-12-01 17:04:46 I just like it a whole lot better. 2023-12-01 17:05:26 I could make some performance arguments. By combining the comaprison and the control transfer into a single primitive, I get the job done with less work, etc. 2023-12-01 17:05:55 But those are fairly minor performance advantages. 2023-12-01 17:09:20 That's certainly the case with the recursion words. With the conditional return words, I may be gaining in the way I just noted but I'm also swallowing the overhead of an extra call/return, so it may go either way. 2023-12-01 17:09:56 For example, instead of : foo ... IF THEN ... ; I'd have something like 2023-12-01 17:10:12 : bar 0=; ; 2023-12-01 17:10:19 : foo ... bar ... ; 2023-12-01 17:11:02 But you see how short that made my definitions. 2023-12-01 17:11:34 I always claim that it "encourages more factoring." 2023-12-01 17:11:47 which is supposedly good. 2023-12-01 17:17:06 "Because I want to" is always a good reason! 2023-12-01 17:19:25 I also like it that the conditional return instructions involve no "offset" in the code. In fact, next go round I'm planning steps to make the conditional recursion words also not use offsets. 2023-12-01 17:19:43 It's an interesting approach, no doubt 2023-12-01 17:21:36 That does make sense, I sometimes wish for different ways of handling conditionals. Isn't that similar in ways to what colorForth did/does? 2023-12-01 17:21:56 Or at least not using IF...THEN 2023-12-01 17:22:05 To each their own I guess 2023-12-01 17:23:29 I don't know that colorforth had conditional returns. 2023-12-01 17:24:02 I'm not terribly familiar with it, though. Not at all to say that I "invented' the idea, but I did think of it without seeing it described anywhere, and I'd read through most of Chuck's stuff. 2023-12-01 17:24:22 Supposedly advent of code day 1 part 2 is hard, so that will be fun getting filtered on day 1, I've not seen it yet 2023-12-01 17:24:44 Although based on comments I wonder if it isn't actually that hard if you're not trying to use regex 2023-12-01 17:24:53 I may have read something about him not using THEN, but that memory is very vague. 2023-12-01 17:25:05 Sounds like regex has been shooting people in the foot as it classicly does 2023-12-01 17:25:25 Jokes on them because forth doesn't have regex 2023-12-01 17:25:30 Regex is such a broad thing. 2023-12-01 17:26:01 In its earliest incarnation it was quite efficient, but then they started adding things to it that opened the door to pathological cases with terrible performance. 2023-12-01 17:26:21 There's a very good paper about all that... 2023-12-01 17:26:35 https://swtch.com/~rsc/regexp/regexp1.html 2023-12-01 17:26:55 "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)" 2023-12-01 17:27:27 https://swtch.com/~rsc/regexp/regexp1.html 2023-12-01 17:27:36 I'm sure I saw something about conditional returns and conditional calls a long time ago 2023-12-01 17:27:40 Oh, you beat me. 2023-12-01 17:27:42 :-) 2023-12-01 17:27:55 i wouldn't doubt it for a second. 2023-12-01 17:28:03 The shooting in foot is partly just when the problem stops being a regular language, or easy to express as a classic regex 2023-12-01 17:28:13 I thought about conditional calls too, but decided the returns were enough. 2023-12-01 17:31:42 https://www.researchgate.net/publication/220828932_A_parsing_machine_for_PEGs 2023-12-01 17:34:59 Classic regex's converted to DFA's are faster than packrat in practice I would guess 2023-12-01 17:35:03 "Enable JavaScript and cookies to continue" 2023-12-01 17:35:18 I wonder if there's any stats on that 2023-12-01 17:35:34 Apparently the 8085 processor had conditional call and return 2023-12-01 17:35:59 Z80 too I think(?) 2023-12-01 17:36:33 http://z80-heaven.wikidot.com/instructions-set:call 2023-12-01 17:37:00 That's a nice feature. 2023-12-01 17:37:23 Not nice enough to poach for x86 2023-12-01 17:38:13 what about IBM 390 condition code system? 2023-12-01 17:39:10 there is a four way branch instruction that takes the four next cells as the branch destinations 2023-12-01 17:39:16 I'm just not familiar with most of the old IBM systems. I looked into them some, but that was back around college time. 2023-12-01 17:39:53 That sounds pretty powerful. 2023-12-01 17:40:38 That's something that would integrate nicely with my planned "near" call feature, where a near call can be a normal instruction-sized field. 2023-12-01 17:40:43 I'd guess the old mainframes are probably more elegant than the micros 2023-12-01 17:41:27 they had a somewhat larger budget for more transitors or whatnot 2023-12-01 17:42:13 CASE