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