Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



If 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.


what do you mean


Define 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.


you 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


Sure, I prefer not shading but that works too.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: