Level 3, lesson 2

# 3.2 The address of a colon-definition

You can get the address of a colon definition by using the word ''' (tick):

         : add + ;                  \ a colon definition
         ' add . cr                 \ display address

Very nice, but what good is it for? Well, first of all the construction "' ADD" throws the address of "ADD" on the stack. In fact, it is a literal expression. You can assign it to a variable, define a constant for it, or compile it into an array of constant numbers:

         ' add constant add-address

         variable addr
         ' add addr !

         create addresses ' add ,

Are you with us so far? If we would simply write "ADD", "ADD" would be executed right away and no value would be left on the stack. Tick forces 4tH to throw the address of "ADD" on the stack instead of executing "ADD".

Note this only works for your own colon-definitions. It doesn't work for 4tHs built-in words. If you try to, you'll get an error-message. What you can actually do with it, we will show you in the next section.