Page:Forth Dimensions Volume 01 Number 2.pdf/4

From Wikisource
Jump to navigation Jump to search
This page needs to be proofread.

EXTENSIBILITY WITH FORTH

The purpose of any computer language (and its compiler or interpreter) is to bridge the gap between the "language" the machine understands (low level) and a language people understand (high level programming language). There are many choices for human-understandable languages: natural languages and artificial languages. The choice of language. should allow convienient, terse, and unambiguous specification of the problem to be solved by the computer. Ordinarily only a few computer languages are available (e.g. BASIC, FORTRAN, APL). These were designed for certain classes of problems (such as mathematical equations) but are not suitable for others. The level of a language is a measure of suitability of that language for a particular application. The higher the level, the terser the program. By definition, [1] the highest level would allow a given problem to be solved with one operator (or command) and as many operands as there are input data required.

A natural language (e.g. English) might appear to be the best choice for a human-understandable computer language, and for some applications it may be. But natural languages suffer from three limitations: verbosity, ambiguity, and difficulty to decipher. This is partly because the meaning of a given word in dependent on its useage in one or more sentences (called "context sensitive") and because they require complex and nonuniform grammar roles with many exceptions. Specialized vocabularies and grammars permit terse and precise expression of concepts for restricted sets of problems. For example, [2] consider the following definition of a syllogism from propositional calculus:

((P1 ⊃ P2) ⊃ ((P2 ⊃ P3) ⊃ (P1 ⊃ P3)))

This sentence may be translated into English as "Given three statements which are true or false, if the truth of the first implies the truth of the second, this implies that if the truth of the second implies the truth of the third, then the truth of the first implies the truth of the third." Ambiguity is hard to avoid in most natural languages. The English phrase "pretty little girls school" (when unpunctuated) has 17 possible. interpretationst (Try it.) [3]


As for the suitability of traditional programming languages (e.g. BASIC, FORTRAN, COBOL, PASCAL, APL) for "almost all technical problems", try coding the following "sentences" in your favorite computer language:


Quantum Mechanics:

..... HW = EV where H= -(1²/2m) ² + V₁ and & is the energy of the system

Electricity and Magnetism:

V.DE V.BO VxE-. VXH= 1²

Matrix Algebra:

The trace of a matrix is equal to the sun of its eigenvalues.

Organic Chemistry:

3CH₂CH₂OH + Cr₂O + 8H3CH₂CHO(g) +26**** 74₂0

Knitting:

3200 K2 tog.3(5) times, *k1, p2, k1, k3, tog.. k1, p2, k1, p1, k1, p3 tog., k1, p1, p1; repent between 's once more, ki, p2, k1, k3 tog.. k1, p2, ki; k2 tog. 3(5) times; 47(51) sts.

Poetry:

Shakespearean sonnets are in iambic pentameter and consist of three quatrains followed by a couplet.


FORTH is capable of being matched to each of the above relations at a high level. Furthermore, using the FORTH concept of vocabularies, several different applications can be resident simultaneously but the scope of reference of component words can be restricted (i.e., not global). This versatility is because the FORTH language is extensible. In fact the normal act of programming in FORTH (i.e., defining new words in terms of existing words) extends the language! For each problem programmed in FORTH, the language is extended as required by the special needs of that problem. The final word defined which solves the whole problem is both an operator within the FORTH language (which is also a "command") and the highest level operator for that problem. Further, the lower level words defined for this problem will frequently be useable for the programming of related problems.


It is true that popular computer languages allow new functions to be added using SUBROUTINES and FORTRAN-like FUNCTIONS. However these cannot be used syntactically the same as the operators in the language.

PAGE 13
FORTH INTEREST GROUP
P.O. Box 1105
San Carlos, Ca. 94070