Adding comment. 4tH 4tH Forth compiler
விளம்பரம்
விளம்பரம்
CHAPTER 7. 4TH FUNDAMENTALS
7.6
Adding comment
69
Adding comment is very simple. In fact, there are two ways to add comment in 4tH. That is because we like programs with a lot of comments.
You’ve already encountered the first form. Let’s say we want to add comment to this little program:
: *. * . ;
2 3 *.
So we add our comment:
: *. * . ;
2 3 *.
This will multiply and print two numbers
4tH will not understand this. It will desperately look for the words ’this’, ’will’, etc. However the word ’\’ will mark everything up to the end of the line as comment. So this will work:
: *. * . ;
2 3 *.
\ This will multiply and print two numbers
There is another word called ’(’ which will mark everything up to the next ’)’ as comment.
Yes, even multiple lines. Of course, these lines may not contain a ’)’ or you’ll make 4tH very confused. So this comment will be recognized too:
: *. * . ;
2 3 *.
( This will multiply and print two numbers)
Note that there is a whitespace-character after both ’\’ and ’(’. This is mandatory! However the closing paren ) does not have to have a leading blank space. It is optional.
7.7
Text-format of 4tH source
4tH source is a simple ASCII-file. And you can use any layout as long a this rule is followed:
All words are separated by at least one whitespace character!
Well, in 4tH everything is a word or becoming a word. Yes, even ’\’ and ’(’ are words!
And you can add all the empty lines or spaces or tabs you like, 4tH won’t care and your harddisk supplier either.
7.8
Displaying string literals
Displaying a string is as easy as adding a comment. Let’s say you want to make the ultimate program, one that is displaying "Hello world!". Well, that’s almost the entire program. The famous ’hello world’ program is simply this in 4tH:
பதிவிறக்கு
விளம்பரம்