2023-11-01 03:52:12 https://softwareengineering.stackexchange.com/questions/339283/forth-how-do-create-and-does-work-exactly 2023-11-01 03:52:18 Top google result with many resources. 2023-11-01 05:22:41 KipIngram: What's your opinion on VALUE / TO ? 2023-11-01 09:46:14 Can I debug this and see how the stacks look at each step? https://ideone.com/bCAEf9 2023-11-01 09:47:39 .s will print out the top few values on the data stack 2023-11-01 09:47:55 You can just put it in anywhere you want to see the stack 2023-11-01 09:49:48 Oh hey GeDaMo :D 2023-11-01 09:49:57 :P 2023-11-01 09:50:03 Oh good tip, but should be a debugger somewhere too no? 2023-11-01 09:50:18 Possibly, that'll be implementation specific 2023-11-01 09:51:06 Yep 2023-11-01 10:03:46 veltas: I've never bothered to implement VALUE/TO. I regard it as not "compile efficient" and if I ever to need to do that kind of thing I just do it manually. 2023-11-01 10:04:03 I.e., I can change the value of a constant if I want to. 2023-11-01 10:04:21 What does that mean, 'not "compile efficient"'? 2023-11-01 10:04:40 Doesn't TO have to parse a word out of the input stream? 2023-11-01 10:04:54 I.e., do a dictionary search? 2023-11-01 10:05:20 not neccissarrily 2023-11-01 10:05:35 But a value leaves it's value on the stack and not it's address. 2023-11-01 10:05:46 lesse 2023-11-01 10:05:46 So how do you locate what to change without a search? 2023-11-01 10:07:00 If that was a response to me I don't understand it. 2023-11-01 10:08:06 VARIABLE TOFLAG : TO TRUE TOFLAG ! ; : VALUE CREATE , DOES> TOFLAG @ IF FALSE TOFLAG ! ! ELSE @ THEN ; 2023-11-01 10:08:34 you get the idea 2023-11-01 10:08:43 You're creating a hybrid variable / value/ 2023-11-01 10:08:45 ? 2023-11-01 10:08:51 TO can do the lookup at compile time 2023-11-01 10:08:58 How adorably... complex. 2023-11-01 10:09:16 Ok, that's fair, GeDaMo. 2023-11-01 10:09:23 I never got what values in Forth were about 2023-11-01 10:09:30 Still, it's just never appealed to me. 2023-11-01 10:09:37 I don't mind doing an @. 2023-11-01 10:09:53 I just use variables when i'm going to need to change the value. 2023-11-01 10:10:26 if I see a frequent varname @ pair then I just make a word varname@ that just does that 2023-11-01 10:10:51 Or that - right. 2023-11-01 10:11:26 The way I generally look at that, though, it only saves one space in the source code, so I usually don't bother. 2023-11-01 10:11:52 but that is only if I need to shoehorn in much more code into a forth program image 2023-11-01 10:12:40 Right - if your goal was to minimize your space, then it would gain you a cell each time you used it. 2023-11-01 10:13:23 So far I've not actually gotten around to any 'building things' so all my Forth work is on my notebook, and I'm never under pressure to minimize space like that. 2023-11-01 10:14:01 If your compiler is "clever" you might use a superinstruction which combines literal and fetch 2023-11-01 10:17:07 arguably, a variable *is* a constant 2023-11-01 10:17:15 Possibly. To date I haven't written particularly clever compilers, though - my past forths have been very straightforward. 2023-11-01 10:17:26 The one I'm planning is going to have to be pretty smart, though. 2023-11-01 10:17:35 I really am going for compactness this time. 2023-11-01 10:17:56 it'll just return the constant address of where you defined it, where it stores the value 2023-11-01 10:18:09 Yes. 2023-11-01 10:18:46 I think of it the other way around (constant is a variable that auto-fetche), but there is symmetry there. 2023-11-01 10:20:13 I don't implement contant with CREATE/DOES>, but functionally it is nonetheless equivalent to : CONSTANT CREATE , DOES> @ ; 2023-11-01 10:21:15 KipIngram: I was confused because compiling we already have to search names! 2023-11-01 10:21:27 I write a doconst code snit that's basically dovar followed by mov TOS [TOS] 2023-11-01 10:21:46 There's no magnitude difference in compile time and there's potentially runtime space/time efficiency improvement 2023-11-01 10:22:00 The only reason I don't like VALUE is because it seems redundant and not particularly forthy to me 2023-11-01 10:22:21 Yeah, I hadn't thought about being able to do that at compile time. 2023-11-01 10:22:44 Anyway, I have no animosity toward VALUE/TO - it's fine. 2023-11-01 10:22:55 I've just never found it worth writing, that's all. 2023-11-01 10:22:57 I don't think it fits but I get why people do it 2023-11-01 10:23:25 Well, it's "cute" - it showcases one of Forth's interesting capabilities. 2023-11-01 10:24:06 And it does let you have variables that behave a bit more like variables in other languages. 2023-11-01 10:24:40 in C or Python a variable's name gives you the value (well, if it's an rvalue). 2023-11-01 10:24:59 You can convey meaning via that lvalue/rvalue positional choice. 2023-11-01 10:28:37 BCPL had an interesting approach to lvalue's 2023-11-01 10:29:24 I think the assignment statement would dereference automatically if an rvalue was on left 2023-11-01 10:29:31 Something like that 2023-11-01 10:29:51 And there was keyword 'rv' to get an rvalue reference from an lvalue 2023-11-01 10:29:59 Something like that anyway... 2023-11-01 10:38:48 bcpl had rv and lv keywords 2023-11-01 10:39:01 Yeah. APL operators can treat right side and left side operators entirely differently. 2023-11-01 10:39:21 In Forth, if it's pure, a word always does exactly the same thing wherever it appears. 2023-11-01 10:39:46 Well, unless you call interpret and compile actions "different." 2023-11-01 10:39:58 But compile really just mostly postpones the effect until runtime. 2023-11-01 11:08:49 How do you pronounce the word `!`? 2023-11-01 11:08:54 bang? or exclamation? 2023-11-01 11:09:14 Store 2023-11-01 11:09:54 Oh, you mean in general, not Forth? :P 2023-11-01 11:10:11 https://blog.codinghorror.com/ascii-pronunciation-rules-for-programmers/ 2023-11-01 11:10:14 No, in forth :) 2023-11-01 11:10:16 got it 2023-11-01 11:10:36 The forth standard has pronunciations for all the words 2023-11-01 11:11:16 oh, so that standard is usefull for something then 2023-11-01 11:11:16 https://forth.sourceforge.net/standard/dpans/dpans6.htm#6.1.0010 "6.1.0010 ! store" 2023-11-01 11:11:44 It's useful as a reference for some things 2023-11-01 11:11:48 GeDaMo: PHP version of counter https://3v4l.org/0LpJ8 2023-11-01 11:11:56 But has a warning :d Not sure 2023-11-01 11:12:00 Output is correct tho 2023-11-01 11:12:31 I like https://forth.sourceforge.net/standard/dpans/dpansa3.htm#A.3.2.3.2 which describes the control stack 2023-11-01 11:13:39 olle: @ is normally called fetch 2023-11-01 11:14:47 oops 2023-11-01 11:14:49 Will fix 2023-11-01 11:16:08 One of the reasons for words having pronunciations is that Chuck wanted to be able to read code over the phone 2023-11-01 11:16:17 Not a bad idea :) 2023-11-01 11:17:08 Could also be used for voice programming, I suppose :P 2023-11-01 11:17:14 Certainly wasn't a bad idea back then. 2023-11-01 11:17:42 I get amused at some of the guys at my office who always have to have a phone call and can't seem to function very well in Slack. 2023-11-01 11:17:58 how do you get to be an engineer in the twenty-first century without being keyboard fluent? 2023-11-01 11:18:42 I mean, these couple of guys are somewhat older - not "kids" - but SO AM I and I'm completely fine using Slack. Prefer it, actually. 2023-11-01 11:18:49 It's great to have a record of everything. 2023-11-01 11:19:26 I detest Slack and Discord 2023-11-01 11:19:42 Why? I'm honestly curious. 2023-11-01 11:20:02 why? too many bells and whistles and takes up so damn much memory 2023-11-01 11:20:12 Oh, ok - that's fair. 2023-11-01 11:20:23 The RAM aspect, I mean. 2023-11-01 11:20:32 I just don't use the bells and whistles I don't need. 2023-11-01 11:20:41 I find it a great way to interact with other people. 2023-11-01 11:20:57 And I've always felt like I express myself better in writing than I do verbally. 2023-11-01 11:21:01 url previews that auto goatse peeps 2023-11-01 11:21:30 Yeah, I don't attach much value to those. 2023-11-01 11:21:44 I think phonecall demanding folks do not want any records 2023-11-01 11:22:15 not realizing that phonerecorder apps exist 2023-11-01 11:26:50 I think it's just that they can't type. At least not well enough for it not to interfere with there stream of thought. 2023-11-01 11:27:00 Ugh. 2023-11-01 11:27:03 s/there/their/ 2023-11-01 11:28:03 I also find it somewhat amusing when people always start off in Slack with "Hey, you there?" 2023-11-01 11:28:19 Just say what's on your mind - I'll either see it now or see it later. 2023-11-01 11:28:43 It works best when people just COMMUNICATE. The relevant information. 2023-11-01 11:28:44 it's a phatic expression 2023-11-01 11:29:03 what is phatic? 2023-11-01 11:29:39 empathy, socializing, that sort of thing 2023-11-01 11:30:09 in person socializing sure 2023-11-01 11:32:02 I guess that's fair enough. 2023-11-01 11:34:34 Wait the output is not correct at all >< 2023-11-01 11:36:53 Ah reset() vs array_pop() 2023-11-01 11:39:58 I've never really been big on socializing with coworkers. I mean, I like them fine, but I mostly socialize with my family. 2023-11-01 11:40:10 Work to earn money. 2023-11-01 11:43:34 My point on this one, though, is that if you're only willing to communicate actual information on Slack when the other person is actually there replying in real time, you're losing one of the platform's best advantages. 2023-11-01 12:20:48 The main extra smarts that are going into this next project are that I'm going to have a particularly compact way to make "spatially nearby" subroutine calls in this system - the compiler will have multiple ways of compiling calls, and will need to figure out the best one to use in each situation. 2023-11-01 12:21:48 I'm hoping that will combine with my coding style - which is to factor very heavily but in a way that puts the "called" helper words very near their callers - in a way that results in a very compact finished system. 2023-11-01 12:23:07 A variation on the same idea will let me use compact calls to call words that are down at my lowest addresses - the "commonly used" built-in definitions. 2023-11-01 12:23:36 On the other hand, I'll also have a way to call anywhere in my 32-bit address space, that I can fall back on when it's needed. 2023-11-01 12:44:28 olle: Most forth glosseries come with pronunciation guides 2023-11-01 12:44:37 Because spoken names are important for collaboration 2023-11-01 12:44:49 Weird for some people to find out forth is a collaborative language 2023-11-01 12:45:38 Hehe 2023-11-01 12:47:32 Collaborative concatenative language :P 2023-11-01 12:56:56 I need a use-case for create/does> that's impossible to do in a "normal" language that lacks macro capability 2023-11-01 13:02:13 Question 2: Can I make a `pipe` word that takes the xt of all future words until a `endpipe` word? 2023-11-01 13:16:17 Yes 2023-11-01 13:16:28 What do you want to do with the xts? 2023-11-01 13:46:38 olle: Well, when you compile a Forth definition exactly what you're doing is creating a list of xt's you can execute as a batch. 2023-11-01 13:50:20 I'm not thinking of any particularly profound create/does> examples. I used it in my x86_64 assembly words. 2023-11-01 13:50:25 For example, 2023-11-01 13:50:27 : op builds> rot 8 << , does> @ frame @ or src dest comp ; 2023-11-01 13:50:40 op lets me define all of my binary operator instruction words. 2023-11-01 13:52:10 42 0 op .add 8 op .or 16 op .adc 24 op .sbb 2023-11-01 13:52:12 43 32 op .and 40 op .sub 48 op .xor 56 op .cmp 2023-11-01 13:52:14 44 136 op .mov 132 op .test 2023-11-01 13:52:27 42, 43, 44 are just line numbers - not actually source. 2023-11-01 13:53:35 frame is a variable that contains the "skeleton" of all those instructions; the detailed instructions get built by adjust that value. 2023-11-01 13:54:33 adjusting 2023-11-01 13:59:55 What I wind up with is, for example, the ability to say something like rcx rbx .add, or rcx rbx d[] .add etc., and get the correct machine code bytes ticked into my dictionary. 2023-11-01 14:08:02 So, it's not really restricted to create>/does> (I used builds>/does>), but that's something most languages won't let you do. 2023-11-01 14:08:11 Adding new machine code to your environment, I mean. 2023-11-01 14:10:01 An assembly system that completely covered all x86_64 instructions would be nightmarishly large, but I was able to write 1644 bytes of source code that covered that whole list of binary instructions, plus a few unary instructions, and works (as far as I can tell) in all addressing modes (except immediate - i haven't supported that yet). 2023-11-01 14:11:00 So you can cover a lot of ground with not much code. And Forth definitely doesn't need every single instruction. 2023-11-01 14:12:00 Reverse engineering the instruction encoding was... entertaining, to say the least. 2023-11-01 14:13:22 You can see the whole thing here: 2023-11-01 14:13:25 https://pastebin.com/c9NVF00H 2023-11-01 14:14:28 as far as I've tested it, that works. I can aim it at a disk buffer and assemble some code, and provided it ends with a return I have a way of running it. 2023-11-01 14:15:27 I'm mostly interested in it for bootstrapping a new system, so I haven't actually tied it in to my existing stuff so that it will assemble new primitives to my running dictionary, but it wouldn't be that hard to do that. 2023-11-01 14:20:40 The biggest limitation of that code is that it really only supports 64-bit operations. I haven't tackled the smaller word sizes yet. 2023-11-01 14:32:32 Oh, my CCD camera arrived. :-) 2023-11-01 14:37:36 I suspect I will need to work with their tech support to get it working. When I installed the software, I didn't have a root password set, so I am betting it didn't do the udev rules changes it needed to do. Otherwise the software installed fine. I'll just need to hook it up and try it later. 2023-11-01 16:02:42 Well, I'm trying out the Brave browser, to see if it's good enough to let me step away from Chrome. 2023-11-01 16:02:55 Try to run a bit less "corporate." 2023-11-01 16:13:50 I'm already noticing that my fans haven't cut on at all yet. 2023-11-01 16:14:06 I went through and opened all of the same tabs in Brave I had open in Chrome. 2023-11-01 18:17:33 The newest computer I've had with passive cooling on the CPU was from 1998, had a fan for the whole box and CPU was in vertical, a Pentium III 2023-11-01 18:19:42 Or was it a Pentium II? 2023-11-01 18:25:40 Yeah a Pentium II, Compaq Deskpro 2023-11-01 18:49:12 it's all about the pentiums yeah yeah 2023-11-01 19:01:08 Well, initially Brave showed no comments or sidebar video list on my YouTube pages. I had to delete Brave's info in .config and let it re-create it to fix that, which meant signing into everything again. 2023-11-01 19:01:45 Also, Brave doesn't seem to remember tabs session to session - that's a bit of a pain. You can, though, bookmark all tabs and then re-open them en masse in the next session. 2023-11-01 19:20:21 Anything that makes browsing harder is probably good for mental health 2023-11-01 19:44:58 lmao 2023-11-01 19:45:02 Indeed... 2023-11-01 19:45:51 Honestly, though, I browse a lot. However, I do claim that most of it is "worthwhile learning." I go down a few "just for fun" completely frivolous rabbit holes, but that's definitely a minority of my digging around. 2023-11-01 19:46:56 Highlander TV Fanfic Episode MCXVI 2023-11-01 20:05:32 Sounds like worthwhile learning to me