2023-12-01 07:35:40 I'm quite happy using FILE* 2023-12-01 07: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 07: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 07:37:33 I quite like this method of encapsulation in C and use it often 2023-12-01 07:38:05 Makes ABI's more stable too 2023-12-01 07:38:48 I'm not 100% sure what PoppaVic was trying to say about this but just opining 2023-12-01 07: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 07:41:41 Instead to achieve this portably you need to add another level of abstraction on top yourself 2023-12-01 08:35:00 Oh, I hadn't realized that all-caps in a type implied "opaque." That's interesting to know. 2023-12-01 08: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 08: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 08:37:32 You'd give the block # to both of them. 2023-12-01 09: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 09: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 09:03:07 They're saying you should use s_tmpfile() instead in their docs 2023-12-01 09: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 09:04:01 And by saying tmpfile() is unsafe and deprecated they're just creating unnecessary work for people 2023-12-01 09:04:05 But no dice 2023-12-01 09: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 09: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 09: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 09:08:08 And this is now probably necessary for backwards compaibility on some sad programs 2023-12-01 09:08:20 But I say just fix it in the new redist... 2023-12-01 09:08:50 And people think Forth is hard! 2023-12-01 09: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 09:51:32 Conditional return and conditional recursion words. 2023-12-01 09: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 09:52:34 All six comparison cases, < <= = != >= >, then with and without default 0 argument, and also where appropriate signed and unsigned cases. 2023-12-01 09: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 09:53:05 That winds up being over a hundred primitives. :-| 2023-12-01 09:53:33 I have an easy to remember convention for their names, so no real "memorization" was required to use them. 2023-12-01 09: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 09:55:07 So yeah - I have those bases well and truly covered. 2023-12-01 09:55:33 I do everything that way - I don't even have IF THEN, BEGIN AGAIN, DO LOOP, etc. 2023-12-01 09: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 09:56:57 Or, rather, which ones to make primitive instructions and which ones to implement as higher level words. 2023-12-01 10: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 10:02:22 That . prefix isn't a "compiler" thing; it's not supported algorithmically. It's purely a naming convention. 2023-12-01 10: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 10:03:38 : +< ( n1+ n2+ -- n1 ; \ compare two positive numbers 2023-12-01 10:03:50 The most commonly used one, I think, is 0=; or 0!=; 2023-12-01 10:03:54 This word is part of how I would compare numbers without comparison operators if I had to do that 2023-12-01 10:04:24 That's nifty. 2023-12-01 10: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 10:04:53 I leave the definition of U< and < to reader as an exercise 2023-12-01 10:05:33 :-) 2023-12-01 10:06:00 Oh look it's time for my first advent of code 2023-12-01 10: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 10:06:30 That's up to you 2023-12-01 10:14:45 Lovely, another boring parsing exercise to trip up the forthers on day 1 2023-12-01 10: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 10: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 10: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 10:20:32 zx spectrum is back, baby! 2023-12-01 10:21:11 Oh, it's up for sale again? 2023-12-01 10:21:37 The main computer from the past I'm a little sorry I missed out on was the Amiga. 2023-12-01 10:21:58 well you said it was a spectrum... 2023-12-01 10:22:06 OH. 2023-12-01 10:22:14 Ha - I didn't catch on those were related. 2023-12-01 10:22:17 Gotcha. 2023-12-01 10:33:01 Parsing thing is re advent of code 2023-12-01 10:36:30 Ah that makes sense, is there any reason for doing it that way though? 2023-12-01 10:37:47 YEah, the Amiga was really supposed to be a radical improvement.. That disappeared. 2023-12-01 10:45:23 hello-operator: What's that regarding? 2023-12-01 10:56:22 In regards to the conditional returns replacing the normal primitives 2023-12-01 10:57:51 KipIngram: ^ 2023-12-01 10:58:25 Yeah, my bad, should've prefixed my comment :/ 2023-12-01 10:58:47 No harm done 2023-12-01 11: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 11: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 11:04:46 I just like it a whole lot better. 2023-12-01 11: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 11:05:55 But those are fairly minor performance advantages. 2023-12-01 11: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 11:09:56 For example, instead of : foo ... IF THEN ... ; I'd have something like 2023-12-01 11:10:12 : bar 0=; ; 2023-12-01 11:10:19 : foo ... bar ... ; 2023-12-01 11:11:02 But you see how short that made my definitions. 2023-12-01 11:11:34 I always claim that it "encourages more factoring." 2023-12-01 11:11:47 which is supposedly good. 2023-12-01 11:17:06 "Because I want to" is always a good reason! 2023-12-01 11: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 11:19:43 It's an interesting approach, no doubt 2023-12-01 11: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 11:21:56 Or at least not using IF...THEN 2023-12-01 11:22:05 To each their own I guess 2023-12-01 11:23:29 I don't know that colorforth had conditional returns. 2023-12-01 11: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 11: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 11: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 11:24:53 I may have read something about him not using THEN, but that memory is very vague. 2023-12-01 11:25:05 Sounds like regex has been shooting people in the foot as it classicly does 2023-12-01 11:25:25 Jokes on them because forth doesn't have regex 2023-12-01 11:25:30 Regex is such a broad thing. 2023-12-01 11: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 11:26:21 There's a very good paper about all that... 2023-12-01 11:26:35 https://swtch.com/~rsc/regexp/regexp1.html 2023-12-01 11:26:55 "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)" 2023-12-01 11:27:27 https://swtch.com/~rsc/regexp/regexp1.html 2023-12-01 11:27:36 I'm sure I saw something about conditional returns and conditional calls a long time ago 2023-12-01 11:27:40 Oh, you beat me. 2023-12-01 11:27:42 :-) 2023-12-01 11:27:55 i wouldn't doubt it for a second. 2023-12-01 11: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 11:28:13 I thought about conditional calls too, but decided the returns were enough. 2023-12-01 11:31:42 https://www.researchgate.net/publication/220828932_A_parsing_machine_for_PEGs 2023-12-01 11:34:59 Classic regex's converted to DFA's are faster than packrat in practice I would guess 2023-12-01 11:35:03 "Enable JavaScript and cookies to continue" 2023-12-01 11:35:18 I wonder if there's any stats on that 2023-12-01 11:35:34 Apparently the 8085 processor had conditional call and return 2023-12-01 11:35:59 Z80 too I think(?) 2023-12-01 11:36:33 http://z80-heaven.wikidot.com/instructions-set:call 2023-12-01 11:37:00 That's a nice feature. 2023-12-01 11:37:23 Not nice enough to poach for x86 2023-12-01 11:38:13 what about IBM 390 condition code system? 2023-12-01 11:39:10 there is a four way branch instruction that takes the four next cells as the branch destinations 2023-12-01 11: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 11:39:53 That sounds pretty powerful. 2023-12-01 11: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 11:40:43 I'd guess the old mainframes are probably more elegant than the micros 2023-12-01 11:41:27 they had a somewhat larger budget for more transitors or whatnot 2023-12-01 11:42:13 CASE