So far we've only used ''' (tick) with colon-definitions, but you can also use it with all constants, variables, values, strings and constant arrays. However, the information it provides is not always useful. E.g. the expression:
10 constant ten ' ten
Does not compile differently from:
10 constant ten ten
The same applies to constant arrays and strings. It will give you possibly information on the address of variables and values, e.g.:
variable ten ' variable ." Relative address of ten: " . cr
Yes, RELATIVE address! What does that mean? When a 4tH program is compiled it has no idea how many application variables a host program will provide. So it stores a RELATIVE address. This address is relative to the address returned by 'FIRST'. You might call it an offset if you want to. So this piece of code does exactly the same thing:
variable ten ten \ throw address of 'ten' on stack dup \ duplicate address 10 swap ! \ store 10 at address ? cr \ show value stored at address
As this piece of code:
variable ten ' ten cells first + \ calculate address dup \ duplicate address 10 swap ! \ store 10 at address ? cr \ show value stored at address
There are not too many occasions where this is useful, but it let's take a look at this one:
0 value ten \ define a value ' ten cells first + \ calculate address of value dup \ duplicate address 10 swap ! \ store 10 at address ? cr \ show value stored at address
We already know that values are stored in the very same area of the Integer Segment. This construction makes it possible to access them as variables.
You should avoid these kind of constructions, but there might be some situations out there where it might come in handy. Note that you can only tick your own names. All of 4tHs built-in variables, strings, words, etc. cannot be accessed by tick.