3 ms·
The other issue, specifically in Forths, is that it's not immediately obvious WHEN an argument is processed. For example, you could have a construct such:
by whartung 4y ago
The other issue, specifically in Forths, is that it's not immediately obvious WHEN an argument is processed.
For example, you could have a construct such:
( read first block from FILE.SCR )
OPEN FILE.SCR 1 BLOCK
But if you try to define a word to do that:
: get-block OPEN FILE.SCR 1 BLOCK ;
You will find the second one doesn't work because OPEN is special, reading from the input stream for the filename at RUN TIME, not COMPILE time.
The OPEN command is more suited to the immediate "shell" experience, than for use in code. But it's not obvious, certainly not immediately apparent at first sight. Need to dig into the documentation is understand the difference.
- astrobe_ 4y agoNot the best example. The lack of quotes around file.scr is an extra-giant-huge hint that OPEN does some parsing, and therefore you should check the docs before using it in a definition (actually it is so very likely that it "won't work" in a definition that you won't even bother checking the docs). Example aside, this type of word is usually used in a DSL-y way and with parsimony. Confusing uses are to be filed in the misuse/abuse category.