![]() |
You. Forth. Simplicity. |
reload node | edit | recent changes | front page
An alias is simply a new dictionary entry for a given word. This procedure uses a word's execution token, i.e. the address of it's compiled code. "alias foo" takes an xt from the stack, and creates a word in the dictionary named foo.
This is useful in conjunction with anonymous functions, which lack a dictionary entry to begin with. It is also useful (along with ') for creating two identical words without wasting codespace.
In the first example, a total of two functions are created and given the names 'foo' and 'bar'. In the second and third examples, one function is created and is given two different names.
'alias' is useful with the loc: and ;loc tags, which remove names from the dictionary, because usually you will want to create at least one word from the code contained within them. 'alias' is interchangable with 'is' in most instances, the exception being that 'alias' always creates a new word name, whereas 'is' will change the vector of an existing word.