home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
tutor
/
l1p075
< prev
next >
Wrap
Text File
|
1990-05-16
|
3KB
|
60 lines
╔══════════════════════════════════════════════════════╗
║ Lesson 1 Part 7.5 F-PC 3.5 Tutorial by Jack Brown ║
╚══════════════════════════════════════════════════════╝
┌────────────────────┐
│ Crashing Forth │
└────────────────────┘
WARNING WARNING!!! it is very easy for an inexperienced FORTH
programmer to CRASH the system. You have probably already done it! The
reason is that most FORTH words take parameters preceding the word. If
you don't provide parameters or give invalid ones all #$!! will break
loose. There are also common FORTH words that look harmless. The
word TYPE is an example. If you want to crash your FORTH system
type: TYPE <enter> and prepare to reset!! We will talk about the
correct way to use TYPE later. Other words to avoid are FILL ERASE
CMOVE MOVE , that is until you are sure you are feeding them valid
parameters on the stack.
Another common error is leaving out the trailing " of the ." " pair
This will produce very odd results. Go back to you phone list and
remove a " and experience the weird sensation! Much better for it to
happen when you are prepared for it.
The concept behind this next crash technique is a little advanced but
most beginners probably do this many times with out knowing what has
happened. Have you noticed that the <enter> key and the "right square
bracket key" or " ] " are located very close together? It turns out
that " ] " is a Forth word and very often a novice and even intermediate
Forth programmers will accidentally strike the " ] " key instead of the
<enter> key. Often they are so quick that they don't even realize that
the wrong key has been pressed and will quickly press <enter> again.
Here is what HELP ] says about this Forth word.
] ( -- )
The Compiling Loop. First sets Compile State. Looks up the next word in
the input stream and either executes it or compiles it depending upon
whether or not it is immediate. If the word is not in the dictionary, it
converts it to a number, either single or double precision depending on
whether or not any punctuation was present. Continues until input stream
is empty or state changes.
So, what does this mean? Well, you won't get the " ok " prompt any more
and every thing you type will get compiled into the dictionary. It will
appear that the system has gone dead! Forth will not recognize any
words at all. Most novices will resort to resetting the machine and
curse at Forth!
But there is an easy solution. " ] " turns the compiler on. Guess
what... " [ " or "left square bracket" will turn the compiler off
again. You should start up Forth now and try this CRASHing technique.
We can tell you from experience that out of a class of 10 people there
will be 2 that can't reach the <enter> key and hit " ] "
occasionally.
┌───────────────────────────────────┐
│ Please move to Lesson 1 Part 7.6 │
└───────────────────────────────────┘