IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Re: Okay, I'll bite
:)

Forth uses white space for delimiters. All other printable characters can be the name of a word (e.g. function or subroutine) in Forth.

Forth words generally take their arguments from an implicit data stack and return the results to that same stack. For example ...
   1 2 + .
pushed a 1 onto the stack, then pushes a 2 onto the stack. It then executes the + word which adds the top two stack entries (and removes them), then pushes the result back on. The . word will print the top number in the stack.

To define a new word, use a colon, the new word name, a list of words and a semi-colon to terminate the definition... so
   : add1-and-print   1 + . ;   ( n -- )
will add a 1 to whatever is on the stack and print the result. The net change in the stack is that it is one element shorter and the stack comment in parenthesis expresses that. A stack comment is a before and after snapshot of the top of the stack.

Variables in Forth are implemented as addresses. "variable x" will create a word named "x" that leaves its address on the stack. Use
   @    ( addr -- n )    To fetch a value\n   !    ( n addr -- )    To store a value
Ok, here's our function written out long hand ...
   : ?     ( addr -- )   \\ Define a word named ?\n     @     \\ Fetch the value stored at the given address\n     .     \\ Print the value at the top of the stack\n     ;     \\ Terminate the definition\n\n   \\ Now we can write ...\n\n   variable x     10 x !     \\ Create a variable x and store a 10 there\n   x ?                       \\ Print the value of x
That's it. : ? @ . ; defines a function that prints the value of a variable.
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Damn.. I could do that!
..for rather small values of do.

As an only-ever dabbler, I have waded through a number of Manuals. Long ago. FORTH I never got to play with, but have been aware of its afficionados since the PDP-8, Modcomp days (or near that). Natch I was unable to participate in evaluation, via ignorance.

(It also helps that your lucid explanation -alas- is not the style of the frequent manual 'writer', I think. Damn few examples within the terse-besotted scribe.)

{sigh} that I can comprehend a certain amount of the 'conflicts' expressed in these columns ie and importantly.. as Expressed in these columns: has led me to believe that - either the denizens of zIWE are atypical or, most of the outside Language Warz derive more from highly-personal pique/preference than from solid comprehension of the bloody tools: by the adversaries.


Just a comment from the unanointed-in-the blood.
..almost enough for me to imagine reading A FORTH book (!) just to see what 'Clarity' might mean in context ;-) Thanks for the sample!


Ashton
Octal seemed like such a Good Thing..
I could remember 8, but 16 --
New Forth Book Recommendations
There are a couple Forth books that really break the mold when it comes to technical manuals. I would recommend "Starting Forth" by Leo Brodie as a good introduction to the languages. Leo's style is casual and fun to read. The cutesy pictures are a bit over the top, but it works.

I also liked "Thinking Forth" by the same author. TF throws a splash of cold water on the traditional engineering approach to software development. It is a bit anti-structured, a bit anti-OO, but in a way that turns your way of thinking around. Its hard to describe. The absolute best part of the book are the captioned illustrations. Priceless.

Both books are out of print, but used copies are available on the net.
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Re: Forth Book Recommendations
Yep - and his whole point was on effective development, not just language mechanics.

There's a book by Salman, Tisserand and Toulout, very thin but deep.
-drl
New Thanks - your opinion is obv shared:
These comments at Amazon, while looking for prices (I use their links for used from small booksellers, wherever I can).
More than a FORTH text, March 28, 2003
\tReviewer: A reader from Longmont, CO United States
Thinking FORTH is as much about philosophy of problem solving and programming style as FORTH. Concepts presented in this '84 publication were light years ahead of their time. OOPs concepts, including data encapsulation, modularity and overloading are explained in simple understandable terms (although with different terminology). Emphisis is on eligance, flexibility and reusability, written in Leo Brodie's unique style. (NO YOU CAN'T HAVE MINE!) --This text refers to an out of print or unavailable edition of this title.
I'll keep eye peeled for a dog-eared version; price reflects the Worth apparently now assigned to both of these (how odd when Econ theory occasionally works..;-) besides, I Love er prescience.. "'light-years ahead' in '84"


Ashton
     Kata Two - Jim Weirich - (ChrisR) - (12)
         Yeah baby! - (deSitter) - (4)
             Forth primitives - (ChrisR) - (3)
                 Re: Forth primitives - (deSitter) - (2)
                     Three years out of date? - (admin) - (1)
                         Curious - (deSitter)
         Re: Kata Two - Jim Weirich - (JimWeirich) - (6)
             Okay, I'll bite - (drewk) - (5)
                 Re: Okay, I'll bite - (JimWeirich) - (4)
                     Damn.. I could do that! - (Ashton) - (3)
                         Forth Book Recommendations - (JimWeirich) - (2)
                             Re: Forth Book Recommendations - (deSitter)
                             Thanks - your opinion is obv shared: - (Ashton)

The following is a paid announcement.
84 ms