27.10.2013 Views

5 - Forth Interest Group

5 - Forth Interest Group

5 - Forth Interest Group

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

NOW . . . . ;<br />

Define an immedia'te word which<br />

executes by the interpretation<br />

of sequential compilation<br />

addresses, and will execute<br />

when encountered during<br />

compilation.<br />

CREATE <br />

As in FORTH-79.<br />

n CONSTANT <br />

As in FORTH-79.<br />

VARIABLE <br />

As in FORTH-79.<br />

VOCABULARY <br />

As in FORTH-79, but each<br />

defined<br />

immediate.<br />

vocabulary is<br />

When the programmer creates new<br />

word types, a significantly different<br />

syntax is used, as compared to<br />

FORTH- 7 9 .<br />

DOES> . . . . ;<br />

Begin the nameless run-time<br />

high-level code for words to<br />

be defined by .<br />

BUILDS> . . . . ;<br />

<br />

Define which, when later<br />

executed will itself create a<br />

word definition. The code<br />

after executes after<br />

creating the new dictionary<br />

header for to aid par-<br />

ameter storage. The previous<br />

run-time code is assigned to<br />

each word created by<br />

.<br />

When new classes of words are created<br />

with their run-time execution<br />

expressed by machine code, their<br />

defining word is created thusly:<br />

CODE> . . . . ENG-CODE<br />

Begin the nameless run-time<br />

machine code for words to be<br />

defined by .<br />

BUILDS> . . . . ;<br />

<br />

Define which, when later<br />

executed will itself create a<br />

word definition. The code<br />

after executes after<br />

creating the new dictionary<br />

header for to aid<br />

parameter storage. The<br />

previous run-time code is<br />

assigned to each word <br />

created by .<br />

THE METHOD<br />

We will follow the method of the<br />

honey bee. To propagate the colony<br />

the bees need a queen bee. An ordi-<br />

nary bee is fed special hormones to<br />

become a queen bee. By regulating<br />

this process the colony regulates its<br />

growth.<br />

Our queen bee will be BUILDS) .<br />

It is originally created as a colon<br />

definition. Then it is converted<br />

into a new type of word that creates<br />

words which always create. This form<br />

uses parameters to create a dictionary<br />

entry and then passes control to the<br />

users code which specifies completion<br />

of the entry.<br />

We will break the CREATE DOES><br />

construct into two parts. The creat-<br />

ing part will be called BUILDS> with<br />

the right pointer emphasizing that<br />

the following word 'builds' other<br />

Page 124 FORTH DIMENSIONS II/5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!