Thanks a lot for your answers both 4th and ANS
After reading your reply I have some more questions...
1. As far as I remember from 4th manual reading Code Segment is the memory where all code is stored, in particular, colon word definitions. If so, this is equivalent to dictionary in classical forths, so you can say both 4th and most forths "store :noname definitions in dictionary as anonymous words" since they are anonymous you cannot look them up using FIND or similar, there's no way to locate a created :noname word after creation. Ok, so the only way to use it is saving its xt somewhere after creation, for example in a variable defined in your code.
But then my question is, how do you free the memory used by a :noname word? in most forths storing :noname words in dictionary means dictionary will grow with every :noname word created without any way to reclaim the memory, same in 4th as you cannot reclaim the memory in code segment, I understand.
But my understanding is :noname word is a temporary word by definition, you use a :noname word as anonymous code similar to lambdas in other languages, code you pass or use locally and temporally. If it's temporal it should be possible to free up the memory use when not needed anymore (automatically by the system or manually by the user)
It can be argued :noname words are not temporal because you can use it for entire program life (for example using them in defers or storing in a variable for common and frequent use) but then what is the advantage of using :noname words rather than normal defined words?
I suppose :noname is somehow related to quotations but I find quotations much more interesting and useful since you can use combinators (also I suppose quotation code is compiled in the same word using the quotation, in its parameter field)
Also if :noname hasn't got a name and no entry in the symbol table, how do you locate it to remove it from memory? I suppose the only way is to find its xt and maybe long traversing the symbol table (or dictionary) but so the system have to keep track of all :noname xt's created, It's not clear to me, can you explain deeper the internals in 4th?
2. I faced this issue for a very specific problem, not common at all, I know of the special kind of question and very weird programming.
The problem I faced is in a fig-forth implementation for a old 8-bit computer: abersoft forth for zx spectrum. I have the need to create an autorun program in this forth in a way the forth code is loaded from tape and automatically run after loaded. Abersoft forth has a basic interface to zx spectrum basic, you can exit to basic with a forth word and then do a warm or cold entry from basic into forth. So I can make a loader and saver in basic that saves or load chunks of code or even the whole memory with current state of forth interpreter with all words I have created. The problem is how to tell forth, from basic, to call a word and execute it. My first idea was to push an xt into stack from basic and then do a EXECUTE in forth, in order to do this I need to access the forth stack from basic and so I need to know the real address of SP and poke values directly into stack memory from basic. As I said very specific issue, but from there I was thinking about how would you do this in forth itself, just for fun (I didn't find a way at least not a good way).
As you can see my intention was not to use locals, but access forth stack from basic in order to communicate with it. Anyway I've seen your video about locals already (I'm very fan of you back and forth content) but honestly I didn't understand it very much, I know its about playing with return stack but it's a bit advanced code for me. Anyway I'm not a big fan of locals ;-)
3. The 4th solution is very clean and smart because you can also cheat the resulting C code, as far as I remember the C code is more or less a big array with all forth code, all 4th segments and a interpreter in C to run the code, very similar to a VM implemented in C. The only cons if any is you dump all code to C, there's no way to translate to C only the words you really need , I know it's a minor complaint anyway. Is there any limitation in size of programs? I mean how 4th handles the problem of having several memory segments? (i mean a segment for code (.text). data (.data) etc, in a segmented memory map common to x86 processors)
thanks a lot for your replies and videos, I always learn a lot from you
regards