2021-12-06 00:11:09 i'm still trying to get my head around postpone ... would this be valid? : abort" postpone IF postpone ." postpone abort postpone THEN ; immediate 2021-12-06 00:11:56 is there any example stack effect notation for words that affect the return stack and the data stack? 2021-12-06 00:20:18 imode: this is from the standard: https://forth-standard.org/standard/core/toR 2021-12-06 00:21:26 i'm sure the standard mentions stack effect comments but so far i can't find it 2021-12-06 00:22:38 aha, neat. 2021-12-06 00:23:07 reason I ask is that my backing data structure is a deque rather than two stacks. still working out the syntax, so I'm wondering how others handle that notation. 2021-12-06 00:24:30 forth is hard 2021-12-06 00:27:33 a statement so true it cleaved the universe in half. 2021-12-06 00:28:38 haha 2021-12-06 01:49:30 dave0: wrt postpone, the thing I found helpful was 2021-12-06 01:49:46 for e.g. 2021-12-06 01:49:56 : foo bar POSTPONE baz quux ; IMMEDIATE 2021-12-06 01:50:11 : xyzzy frob foo spam ; 2021-12-06 01:50:36 you can imagine that if the semantics of immediate are approximately to expand the definition in []'s 2021-12-06 01:50:54 so : xyzzy frob [ bar POSTPONE baz quux ] spam ; 2021-12-06 01:51:06 then POSTPONE's effect is to remove itself from the []' 2021-12-06 01:51:17 eg : xyzzy frob [ bar ] baz [ quux ] spam ; 2021-12-06 01:51:28 and this works regardless of whether baz is immediate or not 2021-12-06 01:53:55 remexre: i think i can follow that 2021-12-06 01:55:16 remexre: there's lots of comments on the postpone standard page which i read closely: https://forth-standard.org/standard/core/POSTPONE 2021-12-06 01:55:27 ah yep, that's from there 2021-12-06 02:06:48 i thought postpone could be written like : postpone ' compile, ; because i had only applied it to immediate words so far, when i was writing the control flow words eg. : REPEAT postpone AGAIN postpone THEN ; 2021-12-06 02:07:10 I think that's [COMPILE] ? 2021-12-06 02:07:33 my definition is https://git.sr.ht/~remexre/spn/tree/b3ff4e10155fa7692dd4622cb067ad3ae711e2fd/item/src/00-lang/00-bootstrap.fth#L70 2021-12-06 02:07:43 adapted from a spec comment iirc 2021-12-06 02:11:21 oh, worth mentioning that MUST-FIND-WORD is ( name-addr name-len -- xt flag ), where the flag is whether the immediate bit is set 2021-12-06 03:11:25 hey remexre 2021-12-06 03:12:11 sorry about that, my lady friend came here and i left without another thought (and accidentally left the stove on! by the grace of god there was no fire!) 2021-12-06 03:14:25 remexre: got it! 2021-12-06 03:15:36 lots of comments 2021-12-06 03:19:04 you compile : and ; in forth without primitive : or ; ! 2021-12-06 03:19:21 forth is weird haha 2021-12-06 07:58:47 i ended up with this, it's weird! i had a bit of chicken-and-egg problem with the else branch so i expanded it inline. : postpone ( "word" --) ' dup immediate? IF compile, ELSE lit lit compile, , lit compile, compile, THEN ; immediate 2021-12-06 08:00:06 if you don't have to read it twice to understand, you're a awesome forther 2021-12-06 08:00:36 :-) 2021-12-06 08:08:06 What does 'lit' do? 2021-12-06 08:10:02 'raw' words are how I tend to resolve the chicken and egg problems 2021-12-06 08:10:37 it's a factor of literal, it pushes the following word in the threaded word onto the data stack 2021-12-06 08:11:12 5 literal would be compiled to lit 5 2021-12-06 08:11:28 veltas: what's a raw word? 2021-12-06 08:11:47 Stuff like (if), (?do) etc 2021-12-06 08:11:59 yeah yeah that's what lit is 2021-12-06 08:12:05 The words that you put in a compiled definition that perform the action associated with some high-level word in execution-time 2021-12-06 08:12:27 I still don't understand lit 2021-12-06 08:12:50 So it is immediate, parses the next word, if it's a word then it finds it and puts its xt somewhere? 2021-12-06 08:13:23 Oh I get it now 2021-12-06 08:13:40 it only took you a few minutes 2021-12-06 08:13:45 it took me 3 days! 2021-12-06 08:14:18 and i didn't even write the code! i copied it from the example implementation from the standard 2021-12-06 08:14:22 It doesn't parse anything, it is (lit) and gets the next 'word' you compile because it gets the next 'word' embedded in the colon def? 2021-12-06 08:14:41 yes exactly 2021-12-06 08:14:52 I guess I can pat myself on the back for not copying much from the standard examples 2021-12-06 08:15:11 The only stuff I copied was arithmetic where I didn't understand the definition 2021-12-06 08:15:29 Like what the hell is 'floored division' etc (I know now, don't actually tell me) 2021-12-06 08:15:44 ah! i studied that 2021-12-06 08:16:28 i read a pdf called divmodnote.pdf it went into excrutiating detail about how to divide numbers that might be negative 2021-12-06 08:16:46 "compile, ," doesn't make sense, I'm assuming your dictionary data and code all goes to one place? 2021-12-06 08:17:42 dave0: I'm not sure that postpone definition is correct 2021-12-06 08:17:54 yes there's only 1 address space ... it runs on msdos 2021-12-06 08:18:10 In that case they might as well write ", ," 2021-12-06 08:18:18 There is no distinction, if there was then that code wouldn't work 2021-12-06 08:18:32 You can't get the 'next' embedded word if it's not embedded with the code 2021-12-06 08:18:42 You see what I mean? 2021-12-06 08:18:57 yep but it's not separate 2021-12-06 08:19:09 numbers are compiled inline 2021-12-06 08:19:11 strings too 2021-12-06 08:19:19 it's an indirect threaded forth 2021-12-06 08:19:31 Yes but I'm saying it's pointless for them to have ',' and 'compile,' in code that assumes they all do the same thing 2021-12-06 08:20:00 ah i needed to make the distinction because of the silly segmentation in msdos 2021-12-06 08:20:25 Okay 2021-12-06 08:20:50 Why not sfind? 2021-12-06 08:21:01 Or non-counted find? 2021-12-06 08:21:17 immediate? is kind of pointless 2021-12-06 08:21:46 oh i am very non-standard 2021-12-06 08:21:54 So no find at all now? 2021-12-06 08:22:01 find is a good word to have 2021-12-06 08:22:14 i have a word called find but it only returns an xt 2021-12-06 08:22:32 immediate? works on xt's 2021-12-06 08:22:38 Yeah that makes sense 2021-12-06 08:23:19 : immediate? flags imm or 0<> ; \ something like this? 2021-12-06 08:23:46 yep 2021-12-06 08:24:41 : immediate? ( xt -- flag) cell- @ IMM and 0<> ; where IMM is the constant 0x10000000 2021-12-06 08:25:02 i put the flags and name at negative offset from the xt 2021-12-06 08:25:06 So your flags immediately precede the code field 2021-12-06 08:25:10 yep 2021-12-06 08:25:25 Have you got the name in a fixed-size field or is it preceding the flags? 2021-12-06 08:25:33 precedes the flags 2021-12-06 08:25:41 Can you walk backwards to the name? 2021-12-06 08:26:53 yes 2021-12-06 08:27:12 How is that possible? Is the size stored at end, is there a special bit set at start/end of name? 2021-12-06 08:28:03 it goes code code code where length and flags are bytes and name is variable length 2021-12-06 08:28:33 so flags is at -1 from the xt, length is at -2, and name is -3 - length 2021-12-06 08:28:37 Where's the pointer to previous definition? 2021-12-06 08:28:48 yeah link is in there too 2021-12-06 08:29:16 Before the name? 2021-12-06 08:29:24 And it links to the previous xt? 2021-12-06 08:29:34 code i packed the bits together so it's not exactly like my picture 2021-12-06 08:29:51 yep 2021-12-06 08:30:20 but the only variable size thing is the name, and you can compute it from the fixed offset length 2021-12-06 08:30:49 Makes sense 2021-12-06 08:31:03 i am going to rewrite this eventually 2021-12-06 08:31:16 What's wrong with that? 2021-12-06 08:32:08 overall it's okay, but the details are pretty ugly 2021-12-06 08:32:13 If you add alignment into the mix, this layout makes even more sense, because the string need not be aligned, so you can start it anywhere after last def to align what follows it 2021-12-06 08:32:16 Should save space 2021-12-06 08:32:36 It's ugly but it doesn't seem to create complexity/work anywhere 2021-12-06 08:32:41 In my mind that's fine 2021-12-06 08:32:50 it was mainly so i could find a name given an xt 2021-12-06 08:33:01 It saves complexity in the sense that you can traverse names/xts in the same way 2021-12-06 08:33:15 Yes certainly you need to be able to switch between the two 2021-12-06 08:33:31 I don't know if it's a standard requirement but there are many important applications 2021-12-06 08:33:48 yeah there's little details like the flags is actually packed into the cell, the link points to the next link not to the code field 2021-12-06 08:34:38 it needs a cleanup 2021-12-06 08:37:20 That direct use of lit is quite clever though, for the right forth 2021-12-06 08:38:12 postpone bends my brain 2021-12-06 08:38:19 i've been thinking about it non-stop for 3 days 2021-12-06 08:38:52 without the example code i would have gone nowhere 2021-12-06 08:39:33 veltas: i've been using jonesforth as a reference, and it's not quite standard 2021-12-06 08:44:34 it's only in the last week or so that i got the compiler working 2021-12-06 08:45:06 Yeah that's what I liked about FORTH when I was learning it, and making a FORTH. There were so many times I just got totally floored by how confusing/complicated it was 2021-12-06 08:45:27 I'm a bit masochistic apparently because I enjoyed that 2021-12-06 08:45:31 it's deceptive ;-) 2021-12-06 08:46:03 i personally was already used to reverse polish notation, but i can imagine people having trouble with it 2021-12-06 08:46:56 then you have to move things around on the stack dup swap over etc. which is very different to c and most languages 2021-12-06 08:49:31 after i could compile things, i went to defining the IF ELSE THEN BEGIN REPEAT etc. which led to postpone 2021-12-06 08:50:16 i like it 2021-12-06 08:50:30 i mean the progress 2021-12-06 08:50:43 each new thing builds on the existing things 2021-12-06 08:52:01 writing + in assembler seems so far away lol 2021-12-06 08:52:05 come so far 2021-12-06 09:15:14 Yes it's pretty cool to say you've written a compiler and interpreter, in anything 2021-12-06 09:15:24 FORTH does lead you along 2021-12-06 09:16:44 nice chats veltas 2021-12-06 09:16:56 i'm gonna brush my teeth ready for bed 2021-12-06 13:01:19 dave0: no worries, I went to bed lol 2021-12-06 13:02:06 yeah, I'm hoping this iteration will be the one clean enough to teach a mini-seminar on Forth at my university 2021-12-06 13:05:52 so lots of commenting is happening so I don't need to reconstruct WTF I did later! 2021-12-06 19:28:47 did this channel become invite-only? 2021-12-06 19:30:46 does not seem so 2021-12-06 19:30:56 I could join no probs 2021-12-06 20:11:01 ok, someone sent me an email saying they couldn't join 2021-12-06 20:51:44 weird. 2021-12-06 21:35:43 siraben: I haven't changed anything on the channel settings since setting it up, so not sure why they couldn't connect 2021-12-06 21:42:48 if they tried to join #forth instead of ##forth, their client might not have processed the forward to ##forth; I've received some reports of that in the past, but nothing with info on the actual irc clients that filed to redirect