resman wrote:
JimBoyd wrote:
I had not. I will admit that Forth naming conventions drive me a little crazy. Bracketed, parenthesized, etc. version of other words seems to be more confusing than just picking a new name.
One thing is to disentangle the two. Some people building Forths like to use () around names for inner routines that are not intended to be used in "userland", and/or for names of routines (either Forth or machine language stubs) that are not appropriate for the outer-interpreter to execute.
For instance, in a direct-threaded Forth, a compiled word starts with a call or jump to a hardware routine which pushes the IP and gets things set up for the inner interpreter to execute the following list of word addresses. The people who like the parentheses words might (ENTER) or (LIST) ... (list of word addresses, that is, not "print to screen") ... but I don't like that style of naming, and I'd call it doENTER or doLIST.
The bracket-y words are something else. When compiling, "... [ <name> ] ..." drops into interpreting state, executes <name>, and then goes back into compiling mode.
So if you have a word that is NOT immediate, which you would often use while compiling with [ ] brackets around, and then you make an immediate version of that word with behavior that works whether you are in compiler or interpreter state, it's a common shorthand to put brackets around it.
And that is what [IF] ... [ELSE] ... [THEN] ... are. They are extremely useful for conditional compilation, and in that context, the surrounding brackets are a visual reminder that they are going to execute, not be compiled.
They are also quite useful for batch processing. In that context, the immediacy is not an issue, but even if you mostly use them for batch processing, using them in the form that also works well when doing conditional compilation means that you already have that tool in your toolkit when needed.
And once you have them, you have multi-line comments for free, using the "0 [IF] ... [THEN]" pattern.
Quote:
I understand that Chuck M. went more down the path of different words for interpreted vs. compiled versions.
While I think that the question of the style of Forth that is most convenient to use to program for matrix networks of Forth processors is an intriguing one, most people who would be using Forth for your kind of application stick to conventional Forth.
Quote:
...
Do you feel its better to stick with (one of) the Forth standard, or go with what feels consistent with the particular usage? I'm definitely on the fence. And thanks for your time!
Note that if you are defining a word with behavior that isn't in a standard word, the most important thing is to avoid giving it the same name as a standard word, which will end up causing confusion if people are trying to refine it or port it for their own use. If you have a word that doesn't work like Forth20xx [IF] ... definitely don't CALL it [IF].
And if you are doing batch processing, you'll want more than just [IF] [ELSE] [THEN] ... you need a batch processing form of a looping constrict, for example ... so there is plenty of opportunity to name your own words your own way.