16.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.

(Figure Nine, continued.)<br />

: @@ \ ( 'body -- obj )<br />

\ check not empty<br />

\ set element context<br />

\ fetch ob j<br />

dup empty? not \ ( -- 'body -f )<br />

if<br />

dup 'obj<br />

swap element-context<br />

DUP CELL<br />

+>R @ ;<br />

We are using here the fact<br />

that all of these systems in-<br />

crement the instruction<br />

pointer and store it on the<br />

return stack when a new<br />

word executes. We can easily<br />

imitate this guide to skip<br />

over embedded data of any<br />

size, and put any information<br />

about it on the stackperhaps<br />

just the starting address.<br />

(I should mention that an<br />

important aspect of <strong>Forth</strong> in<br />

my work is the ability to<br />

seamlessly integrate into a<br />

<strong>Forth</strong> system new and unusual<br />

data types-some systems<br />

have as many as seven<br />

new types, each with appropriate<br />

mechanisms for storage<br />

management, appropriate<br />

handlers, operators, etc.)<br />

The basic control structures<br />

are defined in the same<br />

way in all of these systems.<br />

For example:<br />

: IF<br />

COMPILE ?BRANCH<br />

HERE 0 ,<br />

; IMMEDIATE<br />

: THEN<br />

HERE SWAP !<br />

; IMMEDIATE<br />

(Compiler security has been<br />

ignored I believe all the<br />

above systems use the abso-<br />

lute address rather than a<br />

displacement-but the<br />

change is not a major one.)<br />

With this information, one<br />

can produce any conceiv-<br />

able control structure on any<br />

of these systems by laying<br />

down and resolving the a p<br />

propriate branch instructions.<br />

Uo be sure, some such<br />

structures, like the Eaker case<br />

statement, can be synthe-<br />

sized using standard control<br />

constructs-although with<br />

reduced efficiency.)<br />

In brief, the user has both<br />

knowledge of and control<br />

over what is assembled. The<br />

standard language provides<br />

words (like the control flow<br />

words) that introduce vari-<br />

ants into the normal succes-<br />

sion of addresses constitut-<br />

ing the machine language of<br />

the abstract machine-but<br />

access is there for the user to<br />

do something different In<br />

effect, the user has as much<br />

control over the process of<br />

translating a high-level lan-<br />

guage into "object coden as<br />

does the writer of a compiler<br />

for a conventional language.<br />

The user has the tools to<br />

make a high-level language<br />

look like anything he<br />

wishes-because he has<br />

complete control over the<br />

process of compilation. And<br />

he can do it portably if he<br />

uses "traditional <strong>Forth</strong>."<br />

This is a remarkable and<br />

somewhat subversive idea:<br />

that a user should have power<br />

normally reserved to spe-<br />

cialists. I wouldn't dismiss it<br />

as hogwash if I were you!<br />

From: John Wavrik<br />

Re: Disenfranchised<br />

Mitch Bradley writes,<br />

"Where Dr. Wavrik has<br />

been specific rather than<br />

philosophical (e.g., user-<br />

defined control struc-<br />

tures), the committee has<br />

attempted to deal with<br />

the issues. It would have<br />

saved me a lot of time if<br />

the specific issues had<br />

been presented in the<br />

form of proposals; then I<br />

wouldn't have had to do<br />

the work of writing the<br />

proposals."<br />

In the interest of histori-<br />

cal accuracy, Mitch Bradley<br />

had a proposal he wanted to<br />

submit in this area. He con-<br />

sulted me and a few other<br />

people. I gave him my im-<br />

pression of his proposal, but<br />

he submitted it anyway. I do<br />

(GEnie continued on page 38.)<br />

January 1992 February 32 <strong>Forth</strong> Dimensions

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

Saved successfully!

Ooh no, something went wrong!