2025-02-02 02:04:40 pgimeno I convert the recursive word into a loop 2025-02-02 02:05:04 recurse is immediate and makes a marker for ; to know it's recursive 2025-02-02 02:05:30 then ; creates a special function that will have a loop 2025-02-02 02:05:37 : oh recurse ; 2025-02-02 02:07:26 recurse marks oh as recursive, then ; sees that oh is recursive, it generates a loop with a flag like while ($recursive{$word_name}) { $recursive{$word_name} = 0; for my $code (@code) { $code->(); if ($recursive{$word_name}) { last } } 2025-02-02 02:08:00 the recurse word when executed sets $recursive{$word_name} = 1 2025-02-02 02:08:47 https://i.imgur.com/qKzQ0Ek.png 2025-02-02 02:09:03 I did not test it properly, but what I tried seems to work 2025-02-02 02:10:02 that's the code for ; 2025-02-02 02:10:53 now I have to add does> and I guess ; will grow more than I would like to 2025-02-02 02:10:54 the does> code should be also recursive? 2025-02-02 02:11:20 the standard seems to say does> cannot be used in conditionals or loops 2025-02-02 02:11:48 https://forth-standard.org/standard/core/DOES 2025-02-02 02:17:04 : WEIRD: CREATE DOES> 1 + DOES> 2 + ; 2025-02-02 02:17:42 I have to implement it so it can do that too 2025-02-02 02:17:56 I guess I will try tomorrow 2025-02-02 02:18:19 the rest of today I will read a forth book and implement what I see there 2025-02-02 10:16:04 vms14: a jump for RECURSE only works for tail recursion. If the recursion is not a tail call, you can't return to where it was called from. 2025-02-02 10:21:58 for example, this returns 2*(argument - 1): : test 1- dup 0= if exit then recurse 1+ 1+ ; 2025-02-02 10:22:24 7 test . 12 ok 2025-02-02 10:22:24 13 test . 24 ok 2025-02-02 12:57:10 1+ 1+ never get executed 2025-02-02 12:57:36 : test 1- dup 0= if exit then .s recurse 1+ 1+ ; 2025-02-02 12:57:48 goes from 7 to 0 2025-02-02 12:58:30 https://i.imgur.com/iYv9vYu.png 2025-02-02 13:00:00 you can test yourself if you want to and see whether it works fine 2025-02-02 13:00:19 actually I need to test that the words I have work like in forth 2025-02-02 13:00:27 so some feedback would be appreciated 2025-02-02 13:00:48 https://paste.debian.net/plain/1347994/ 2025-02-02 13:01:05 if you give that file to perl will launch a repl 2025-02-02 13:01:13 although I recommend rlwrap 2025-02-02 13:01:50 but it's missing a lot of words, those are the ones that I have right now 2025-02-02 13:01:54 .( ; colors rot tb :noname ." exit newline edit create here if @ ps k dup spaces .cr [char] swap defer /mod drop , ?dup .s 2drop recurse char tab 2over prompt is emit + i ' 1+ ] . mod .sp ins do f / wipe over ['] cursor : rr " blank j ( 1- allot - space sp no.colors 2+ variable * t cr color .words 2dup 0= ! [ r 2- 2swap .. 2025-02-02 13:02:59 create is not working properly because I was thinking about its behavior yesterday 2025-02-02 13:04:39 vms14: do you have something to tell you the last word added to the dictionary? 2025-02-02 13:04:45 do also behaves a. bit different 2025-02-02 13:04:49 GeDaMo yeah 2025-02-02 13:05:03 that's how ; knows what entry to create 2025-02-02 13:05:39 it's just a global variable that : will set with the name it reads 2025-02-02 13:06:33 create also adds words to the dictionary 2025-02-02 13:07:01 : should be doing the equivalent of calling create 2025-02-02 13:09:20 Do you have a single memory spaceor separate areas for each word? 2025-02-02 13:10:52 the dictionary is a hash table and words are perl functions 2025-02-02 13:10:52 I do have an array for memory as an additional thing 2025-02-02 13:11:11 So the data space is a memory array? 2025-02-02 13:11:20 yes :/ 2025-02-02 13:12:07 $dictionary{$name} = sub { put $pointer }; 2025-02-02 13:12:14 that's what create does 2025-02-02 13:12:28 $pointer is a local copy of $here to retain its value 2025-02-02 13:12:41 Sounds reasonable