2023-10-25 03:59:08 Could you write a Forth program that does like `geturl fetchremotecontent parsecontent`, and then add a cache like `geturl cache fetchremotecontent parsecontent`? 2023-10-25 03:59:32 In the last case, it only fetches content remote on a cache miss 2023-10-25 08:01:49 olle: Yeah probably 2023-10-25 08:06:24 veltas: :) 2023-10-25 08:06:25 Neat 2023-10-25 08:06:53 But the `cache` word have to "color" the `fetchremotecontent` word with new behaviour :d 2023-10-25 08:07:03 Or "wrap" perhaps better 2023-10-25 08:08:36 Yes I think fetchremotecontent would need a special definition to support cache 2023-10-25 08:09:07 Special definition or some kind of wrapping performed after the fact (but before the first use that needs to be cached) 2023-10-25 08:21:20 0 FIELD: CACHE.XT FIELD: CACHE.CACHED? FIELD: CACHE.VALUE CONSTANT %CACHE 2023-10-25 08:21:29 : CACHED ( " name") >IN @ ' SWAP >IN ! CREATE , 0 , 0 , DOES> DUP >R CACHE.XT EXECUTE R> OVER CACHE.VALUE ! -1 SWAP CACHE.CACHED? ! ; 2023-10-25 08:21:40 : CACHE ( " name") ' DUP >BODY DUP CACHE.CACHED? @ IF NIP CACHE.VALUE @ ELSE DROP EXECUTE THEN ; IMMEDIATE 2023-10-25 08:21:48 Something along those lines olle ^ 2023-10-25 08:22:05 Not tested I just spammed some code out, but that might help if you're not sure what features are used to do it 2023-10-25 08:27:00 CACHE should really say ( " name" - x) 2023-10-25 08:27:19 Because it leaves a value, from executing the word or retrieving from CACHE.VALUE 2023-10-25 08:29:32 I need to write that down :d 2023-10-25 09:45:34 olle: This isn't too terribly different from the way Forth's block system works. Under the hood, Forth caches block daTa in "disk buffers." When you say BLOCK, it first checks to see if that block number's data is already resident in one of the buffers, and if it is it just returns you that buffer's address. If it's not resident, it has to go fetch it from disk and it takes a lot longer. 2023-10-25 09:45:41 You're talking about something very similar here. 2023-10-25 09:46:18 KipIngram: Yea sounds like it 2023-10-25 09:46:31 Maybe I should post on a forum to get answers saved :d 2023-10-25 09:46:49 Googled before about a possible combination of Smalltalk and Forth :D 2023-10-25 09:47:02 Each word is an object, the stacks are objects, and the things on the stacks are objects too. 2023-10-25 09:47:21 When Forth stows a block in a buffer, it has to of course record what that block # is; each buffer has a field for that. So in your case here, you'll need a way of saving fetched data and a way to mark each of those with "what they are," so that you can compare against that later. 2023-10-25 09:47:54 For blocks, it's just an integer value - for you it will be a bit more complex. 2023-10-25 09:49:34 I arranged my BLOCK so that it begins as a primitive - that first "is it resident" stuff runs as fast as I could possibly make it run. Then if it discovers it has to go to the disk, it transfers control to a Forth definition. Speed no longer matters as much. 2023-10-25 09:50:14 'stow' is a good word 2023-10-25 09:50:24 So I got the convenience of using Forth to write the slow complex part, while still gettng the speed of a primitive in the cases where it paid off. 2023-10-25 09:50:33 Yes, stow is a nice potential Forth word name. :-) 2023-10-25 09:53:04 olle: With the block system, Forth may re-allocate a disk buffer at any time. So good coding calls for you to say BLOCK every time you're about to access that data, even if you still could have the address lying around from the last time you did it. Forth might have evicted your data behind your back. 2023-10-25 09:53:49 Generally speaking, if you have said BLOCK since you said BLOCK, then you should repeat the BLOCK just to be sure. 2023-10-25 09:54:07 Though hopefully you have resources to cache more than just one. 2023-10-25 10:03:17 Anyway, I guess my point is that Forth can certainly do this, since it already does something similar. You have to implement the details yourself, though. 2023-10-25 10:03:44 I've always thought it's kind of friendly of Forth to do that work for us on disk blocks. 2023-10-25 10:04:37 They could have just given us : blk-read ( addr n --) .. ; and : blk-write ( addr n --) ... ; and left it at that. 2023-10-25 10:43:44 Claude Shannon's masters thesis: 2023-10-25 10:43:45 file:///home/kipingram/Downloads/34541425-MIT.pdf 2023-10-25 10:43:56 Foundational paper in computer circuitry. 2023-10-25 10:45:23 file: refers to your local drive 2023-10-25 10:45:31 Turns out that "Boolean algebra" as normally taught is rather different than "the algebra of George Boole." In some ways Boole's original treatment has some advantages. It was later re-organized to be more "set theory" oriented. 2023-10-25 10:45:37 oh shoot. 2023-10-25 10:45:44 Sorry bout that - one moment. 2023-10-25 10:46:00 Although I'll admit to clicking the link before noticing that :P 2023-10-25 10:46:02 I only use a single block buffer in my system 2023-10-25 10:46:09 https://dspace.mit.edu/handle/1721.1/11173 2023-10-25 10:46:27 I've made that error before. 2023-10-25 10:46:57 His other classic paper, introducing information theory, is also floating around out there and is well worth reading. 2023-10-25 10:47:01 I've not read this one here yet. 2023-10-25 11:22:21 Wildberger is pushing the idea that Boole's original approach to things is better. I actually think he may be right, but the problem is that if you teach that to a student he then goes out into the world never having seen "the standard approach." 2023-10-25 11:22:25 And that's not good. 2023-10-25 11:22:46 So unless you can find a way to shift the whole world, it's probably a change that can't be made. 2023-10-25 11:23:22 That's the same problem as with me saying that we should teach kids geometric algebra instead of the usual approach to vectors. 2023-10-25 11:23:35 You can't leave them ignorant of the standard fare. 2023-10-25 11:23:46 And there's probably not time to do work twice. 2023-10-25 12:39:32 in my Forth words i'm inserting some "quick help" in the classic Forth style, but with my convetions, e.g. ( -1 abs -- 1 ) just to quick see how words work, what you think? 2023-10-25 13:24:00 rendar: looks good to me 2023-10-25 13:26:06 crc, the thing is when you describe a word, like 'abs' you usually show only the stack ( -1 -- 1 ) without inserting the word itself 2023-10-25 13:26:54 sometimes i insert it (or helper words) to make it clearer, for instance, with 'nan?' word which checks if a float is NaN, i do: ( -1.0 ln -- true ) 2023-10-25 13:37:05 Yeah that looks good to me too rendar 2023-10-25 13:37:20 thanks! 2023-10-25 13:45:20 If it's consistent, I think that's fine. Having short examples is a good idea. 2023-10-25 13:49:35 thanks 2023-10-25 13:49:51 i was also thinking: has Forth homoiconicity like Lisp? 2023-10-25 14:06:49 that'd depend on the forth 2023-10-25 14:10:08 I've done a couple of experimental systems in the past where the source & compiled representations could be mutually derived/manipulated in code, but it's not something that seems to be common. 2023-10-25 14:23:28 rendar: I think that looks great. 2023-10-25 14:23:38 How are you storing that information? 2023-10-25 14:23:59 Or is this just how you're going to do comments? 2023-10-25 14:24:13 I.e., is it an actual "help facility"? 2023-10-25 14:25:50 Homoiconicity isn't a usual feature of Forth, like crc said. One issue is that the source <--> code mapping isn't usually bijective. 2023-10-25 14:26:50 I think the new one I'm planning may be, though, which does open the possibility of treating code strings like data. Another potential issue, though, is that I'm planning for my subroutine calls to be relative, so really that code will only work run from the place I put it to start with. 2023-10-25 14:27:07 lisp is the one that does it very aggressively and requires code to support it 2023-10-25 14:27:56 Yes, in that case you keep the actual name of the referenced words in place. In Forth that's generally gone once you compile a word. 2023-10-25 14:47:55 I had a past system in which I would routinely reconstruct source from the compiled representation, but that's very much uncommon and required taking a lot of care in making sure the compiled format was consistent and predictable. 2023-10-25 14:56:03 I do want to try to make that work (decompiling accurately). And it wouldn't be too hard to convert those relative offsets back to addresses if I wanted to pick that code up and do something with it. 2023-10-25 14:56:28 I've just never done much in that kind of environment, though, so I probably don't really know what all the good things to do would be. 2023-10-25 15:51:53 So, what might I do with "code as data"? Anything that needs that code executed can just run it where it is; what do I gain by passing the code itself around rather than just passing its location (i.e., it's xt)? 2023-10-25 15:52:03 s/it's/its/ 2023-10-25 15:54:36 usually crazy macro stuff 2023-10-25 18:15:30 Wow - I continue to be impressed at how much cleaner and more powerful Boole's original algebra was than the standard techniques. 2023-10-25 18:16:14 In modern Boolean algebra, you basically use AND, OR, and NOT and you might write expressions like ABC+A\B(C+D) etc. 2023-10-25 18:16:24 The \ preceding a letter inticates it's inverted. 2023-10-25 18:16:53 In Boole's original setup, you negated by adding 1, and + was exclusive OR rather than standard OR. 2023-10-25 18:17:22 The whole thing is just closer to standard mod 2 arithmetic, so the "algebraic" moves are more traditional. 2023-10-25 18:18:14 Repeated terms in a sum can just be dropped in pairs. Since + is exclusive or, + is zero. 2023-10-25 18:18:39 All of the arithmetic is done mod 2, so where you might have gotten 3 times something before you can just immediately reduce that to 1. 2023-10-25 18:19:00 And exponents can just be ignored - ^n is logically the same as . 2023-10-25 18:19:17 those two rules wind up slicing out a lot of work. 2023-10-25 18:20:27 And, moreover, it's entirely straightforward to reduce an expression to a "canonical form," and two circuits that implement the same function will always reduce to the same canonical expression. So deciding it two circuits are functionally equivalent is entirely a matter of mechanical crank-turning. 2023-10-25 18:20:39 And that's a subtle question using traditional methods. 2023-10-25 18:21:11 Wildberger calls that the "Boole poly-number" of the circuit / expression. 2023-10-25 18:21:45 (poly numbers are a technique I've never seen anyone talk about except him - I assume he invented it). 2023-10-25 18:22:35 Boole poly numbers are even simpler than his normal ones, due to the whole thing being over the binary field. 2023-10-25 18:24:50 Many years ago I was interested in writing software to do various things with digital logic - this makes me feel like that again, only using these methods. 2023-10-25 18:25:35 This is probably the most interesting stuff I've seen Wildberger talk about (to me) because it bears direction on the very foundation of my professional training. 2023-10-25 18:25:42 s/direction/directly/ 2023-10-25 18:28:33 It all makes me wonder why anyone felt the need to adjust Boole's materials in the first place. Maybe it was because he was a dead foreign guy and not a contemporary working at a high falutin' place like Bell Labs or something. 2023-10-25 18:29:20 I mean, why credit a dead guy when you can change a few names and sand the corners down a little and take credit for it? Publish or perish... 2023-10-25 18:30:32 The new stuff is more in tune with set theory, which by the mid-20th century had sort of taken over the basement of all of math - that might be part of it too. 2023-10-25 18:31:10 Wildberger has opinions on that hierarchy too - he thinks the foundation should be arithmetic of natural numbers rather than set theory. 2023-10-25 18:31:47 But his goals don't include establishing a rigorous basis for "the continuum," so it's not surprising he has a whole different starting point. 2023-10-25 18:33:33 If anyone is interested, this playlist is here: 2023-10-25 18:33:35 https://www.youtube.com/playlist?list=PLIljB45xT85CnIGIWb7tH1F_S2PyOC8rb