0.5 Making your own words

Of course, every serious language has to have a capability to extend it. So has 4tH. The only thing you have to do is to determine what name you want to give it. Let's say you want to make a word which multiplies two numbers and displays the result.

Well, that's easy. We've already seen how you have to code it. The only words you need are '*' and '.'. You can't name it '*' because that name is already taken. You could name it 'multiply', but is that a word you want to type in forever? No, far too long.

Let's call it '*.'. Is that a valid name? If you've programmed in other languages, you'll probably say it isn't. But it is! The only characters you can't use in a name are whitespace characters (<CR>, <LF>, <space>, <TAB>). Note that 4tH is not case-sensitive!

So '*.' is okay. Now how do we turn it into a self-defined word. Just add a colon at the beginning and a semi-colon at the end:

     : *. * . ;

That's it. Your word is ready for use. So instead of:

     2 3 * .

We can type:

     : *. * . ;
     2 3 *.

And we can use our '*.' over and over again. Hurray, you've just defined your first word in 4tH!