6 ms·
from my non-expert viewpoint, the big penalty for named local variables in forth is that it is a barrier to breaking up a word into smaller words, because piece
by kragen 4y ago
from my non-expert viewpoint, the big penalty for named local variables in forth is that it is a barrier to breaking up a word into smaller words, because pieces of code inside the same word that communicate through a local variable will stop working if you break them into separate words
bigger words impede using the forth repl as a line-by-line stepping debugger, so they diminish the interactivity that is the reason you'd use want to forth in the first place
agreed about strings; one of the first things i wrote in forth was a straight port of bernstein's stralloc, last millennium
- Karrot_Kream 4y agoIf you can keep variables separate between different words, you can make sure that the variable stays local to the word. It is error-prone but can stop the variable from leaking and keep words separate.
- kragen 4y agowhat do you mean
- Karrot_Kream 4y agoDefine variables before you start defining words. Make sure you use one variable per word. It's a manual process but when composing words helps make sure variable collisions don't happen.
- kragen 4y agoyou don't need to do that, you can define a separate variable named x above every colon definition if you want it hides the earlier declarations of the same name
- Karrot_Kream 4y agoSure, I prefer not shading but that works too.