2025-02-01 01:14:01 how do you guys signal the user is compiling in the repl? 2025-02-01 01:14:17 I have ok when not compiling and no errors and ... when compiling 2025-02-01 01:14:38 although I can also make the repl to print the stack instead of ok 2025-02-01 01:15:01 I guess I will change the prompt when compiling instead 2025-02-01 01:17:56 vms14: I don't have any prompts (so no 'ok') or indicator for compile vs interpret in my systems 2025-02-01 01:21:10 I have it like this now 2025-02-01 01:21:10 https://i.imgur.com/qa1Jmkj.png 2025-02-01 01:21:52 ps changes ok for the stack printing 2025-02-01 01:22:07 but I like that they won't display anything if you are compiling 2025-02-01 01:22:26 ps? 2025-02-01 01:22:45 print stack 2025-02-01 01:22:51 aha, not PostScript 2025-02-01 01:23:06 I was going to say, I don't remember PostScript having that behavior ;) 2025-02-01 01:23:09 it was print.stack but found annoying to use such a large name 2025-02-01 01:23:21 I think .s is the traditional name 2025-02-01 01:23:28 not that there's anything wrong with ps 2025-02-01 01:23:37 I have .s but ps is a flag for the repl 2025-02-01 01:23:37 I was just lacking the context 2025-02-01 01:23:56 the repl prints 'ok' but if you use ps it prints the stack instead of ok 2025-02-01 01:24:23 oh, I see 2025-02-01 07:40:10 vms14: I like that ... for compiling 2025-02-01 07:41:35 Also printing stack instead of 'ok' as an option is a good idea! 2025-02-01 07:42:37 I usually just print 'ok', but I might steal both of those ideas 2025-02-01 09:52:40 agreed, I like the ... 2025-02-01 12:45:17 veltas I like the stack instead because I get tired of using .s 2025-02-01 12:45:43 but since I sort of pretend to be a forth I cheat with those things 2025-02-01 12:46:37 the goal is to cover a subset of forth that makes sense for my case 2025-02-01 12:51:09 veltas note that the ... are the prompt ' >' changing for '...' 2025-02-01 12:51:35 the prompt word looks at the state flag 2025-02-01 12:51:52 and the repl will not print the stack or ok if it's compiling 2025-02-01 17:59:36 I have :noname defer and recurse 2025-02-01 17:59:48 no idea yet how to implement does> 2025-02-01 18:00:14 but I have a memory array which I will use for create, variable, etc 2025-02-01 18:01:36 recurse should be able to recurse indefinitely without blowing the return stack (since it does not exist) and also works with noname definition 2025-02-01 18:02:54 now I have here and allot, which is just a pointer and allot increments it, @ and ! will use that memory array, so you can increment a memory location to provide offsets or accessors 2025-02-01 18:14:54 https://softwareengineering.stackexchange.com/questions/339283/forth-how-do-create-and-does-work-exactly 2025-02-01 18:14:57 this is helpful 2025-02-01 20:05:33 seems I can do in forth: create one create two 24 one ! 3 two ! 2025-02-01 20:05:38 is this expected behavior? 2025-02-01 20:05:48 there is no allocation of space 2025-02-01 20:06:39 You can do it, whether it's a good idea or not is a different thing :P 2025-02-01 20:06:47 You might be overwriting something 2025-02-01 20:07:47 GeDaMo I want to have the same behavior, but this gives me a bit of problem 2025-02-01 20:07:57 if it's expected behavior I should do it 2025-02-01 20:08:16 if not then meh 2025-02-01 20:08:37 I'm using an array to simulate behavior and here is just a pointer for that array 2025-02-01 20:09:03 but since there is no pfa or whatever it will not align properly 2025-02-01 20:09:20 A created word just returns the address of the "data field" which traditionally is the address after the word header 2025-02-01 20:09:22 create should not increment here, but it does in gforth 2025-02-01 20:09:56 well it should maybe 2025-02-01 20:09:58  If the data-space pointer is not aligned, reserve enough data space to align it. The new data-space pointer defines name's data field. CREATE does not allocate data space in name's data field. 2025-02-01 20:11:19 in my case create just creates a word definition that will capture and push the current value of here when executed 2025-02-01 20:12:06 but it says it does not allocate data space 2025-02-01 20:12:19 so shouldn't create one create two fail? 2025-02-01 20:12:29 well access the same memory 2025-02-01 20:14:01 I can make create increment here, but does not seem like it should 2025-02-01 20:16:12 pforth crashes when I set two 2025-02-01 20:16:24 but it also increments here 2025-02-01 20:19:08 Increment what? The dictionary pointer? 2025-02-01 20:33:06 GeDaMo here 2025-02-01 20:33:27 : here dp @ ; 2025-02-01 20:33:37 here create one here .s <2> 504414475616 504414475656 ok 2025-02-01 20:33:48 that's gforth 2025-02-01 20:33:54 pforth also does this 2025-02-01 20:34:02 That's because the header was created 2025-02-01 20:34:07 but gforth seems to allocate enough to save an integer 2025-02-01 20:34:23 gforth is 64-bit 2025-02-01 20:34:35 It'll be incrementing to align the address 2025-02-01 20:34:48 but you can set values without allocating 2025-02-01 20:35:03 create one create two 24 one ! 3 two ! 2025-02-01 20:35:06 Yes, Forth generally doesn't prevent you writing to any memory address 2025-02-01 20:35:09 this works in gforth 2025-02-01 20:35:17 but segfaults in pforth 2025-02-01 20:35:36 segfaults when setting two 2025-02-01 20:35:53 so then I would like to assume that is undefined behavior 2025-02-01 20:36:02 and that I do not have to follow it 2025-02-01 20:36:25 Possibly writing to 'one' overwrites part of the header for 'two' so calling 'two' returns an invalid address 2025-02-01 20:36:39 makes sense 2025-02-01 20:36:48 ty GeDaMo for helping me to understand 2025-02-01 20:36:52 :) 2025-02-01 20:37:12 I will just forget about that and expect the user to allocate space 2025-02-01 20:42:13 It's technically possible for 'header space', 'code space' and 'data space' to be in separate memory regions 2025-02-01 20:45:30 You might also separate machine code from threaded code 2025-02-01 20:46:10 There could be advantages on architectures with CPU caches to have different types of data on separate cache lines 2025-02-01 20:47:56 there is no header space, code space is a perl subroutine and data space will be the memory array xd 2025-02-01 20:48:52 I tried to consider sticking to forth and make the dictionary be a linked list in the memory array with headers and alike 2025-02-01 20:49:04 There is header space, it's just not directly accessible from your Forth code :P 2025-02-01 20:49:04 but it made not much sense at the end 2025-02-01 20:50:53 I might rethink that in the future 2025-02-01 20:50:56 if I keep adding features that push me into that direction I will reconsider if I should start again with this method 2025-02-01 20:51:51 at the end I just want to be able to follow most of a forth book with my interpreter 2025-02-01 20:52:34 but being so different internally will require workarounds, which for now I do by abusing closures 2025-02-01 20:52:44 I'm pretty sure that most Forth programs won't be doing anything fancy with headers, they're mainly used for compiling 2025-02-01 20:53:18 defer for example is a closure xD 2025-02-01 20:54:09 it captures a variable named $code in a closure and the closure will execute that code if no arguments are given, if it takes an argument it will update the $code variable to that value 2025-02-01 20:55:02 the interpreter will call that closure without arguments, the 'is' word will take an "xt" and call that closure with that as the argument 2025-02-01 20:55:14 xt is directly the perl subroutine 2025-02-01 20:55:32 : oh 1 2 3 ; defer ah ' oh is ah 2025-02-01 20:59:35 https://i.imgur.com/dWgKug9.png 2025-02-01 22:04:58 " recurse should be able to recurse indefinitely without blowing the return stack (since it does not exist)" - wait, what? it has to blow *something*, there might not be a Forth return stack but there should be one 2025-02-01 22:06:13 one return stack of sorts, even if it's the Perl return stack 2025-02-01 22:07:59 as for CREATE, I can tell you that the Jupiter implements VARIABLE this way: 1 VARIABLE stuff is equivalent to CREATE STUFF 1 , 2025-02-01 22:30:55 " create one create two 24 one ! 3 two !" - I only know the details of the internals of the Jupiter, so I can only tell you about it. In the jupiter, the first ! will overwrite the first two letters of the name "TWO", and the second ! will be harmless.