by crabbone · 3y ago · 0 comments
This is where it differs from languages which try to guard the scope, but is, in a way similar to the problems created by violating the locality of the problem by using global variables.
I feel like Forth might have evolved to mitigate this problem (as well as many similar ones, like not needing to specify the number or names of arguments to the subroutines, or not really having much structure to the routines that can be expressed through something like paired delimiters or indentation...) but, unfortunately, it didn't. Or, maybe I never found any descendants that would take the language further towards implementing some of the more modern ideas about how to structure large programs.
: SQUARE ( n1 -- n2 ) DUP * ;
I've never run into any checkers for these comments -- though https://stackoverflow.com/a/40321950/68707 indicates that checkers may exist. For example, Gforth (GNU Forth), one of the most popular and full-fledged Forth compilers doesn't do this.To do this, there are some limitations on how the stack can be used compared to regular Forth. (For example, both sides of an IF/ELSE must leave the same number of items on the stack with the same types, but they can have different values. An IF without an ELSE can never change the depth of the stack or what types are on it, since the implicit, empty ELSE side says that the stack doesn't change.) This generally isn't a huge problem, as the things you can't do in StrongForth are usually not such a good idea from a maintenance perspective in regular Forths.