Project

General

Profile

FORTH, unbearable, impossible? - a remark

Added by Rolf about 2 months ago

The first step was easy, because I am familiar with HP-calculators. But when it came to practice, several times I arrived at the point to give up and stay with C/C++. Example code does not help much, it's like chinese. JWC's articles are very helpful, I got to know how to implement loops and branches. But nowbody explains how to pass parameters to functions ("words"). Today I got the enlightement, the final kick to stay with forth. From the C/C++ point of view it's "nobody explains", from the forth corner "silence", because it was explained implicitely long before: Just push the parameter to the stack and let the word pull it off. - Realizing this (the reason why I had a problem to understand) I was that enthusiastic to think it could be helpful writing a forth-introduction from the C-programmers point of view. I should know forth still a bit better before beeing able. And arriving at that point, I shall have lost the C-programmers eyes. - Another impossible aspect of forth.


Replies (4)

RE: FORTH, unbearable, impossible? - a remark - Added by jcw about 2 months ago

Looks like you've "crossed the chasm", as they say... I'm sorry that it's such a difficult path to take.

You've read the Forth in 7 easy steps article, I assume?

My failure perhaps, was to forget to mention that "+" is a word like all the others.
So "1 2 +" does exactly that: pass arguments, via the stack, and return its result, again via the stack.

Yes, Forth will need a lot of care and love, to write good introductory docs, examples, and how-to's.
I'm not sure I'm the one who could write those, as I seem to be unable to get even the basics across well.
All I can say is: I think it's all worth it. Forth is a natural (and delightful) match for low-end embedded µCs, IMO.

PS. I'll see if I can write up another introduction soon, specifically for people familiar with C.

RE: FORTH, unbearable, impossible? - a remark - Added by Rolf about 2 months ago

Exactely that's ("to mention that "+" is a word like all the others ...") what I thought when I finally got it. I was constructing an example function in my mind:

int plus( int i, int k) {
return i + k;
}

Translating this in practice into forth, the polite answer of the interpreter was: "Redefine +. ok.".

I think you do not need to write another introduction, "Forth in 7 easy steps" is already very good. Just to add a few simple things that look too trivial to mention from the forth point of view ("forget to mention that ...") could be useful. And something else, which I found somewhere in the manuals but which is important for the beginner to know: "." does not exactely mean "end of the command" but "pull the value from the stack and display it".

RE: FORTH, unbearable, impossible? - a remark - Added by Rolf about 2 months ago

Finally I did what I was threatening above, writing not another Forth-introduction, no need for that, but some
"Beginners Remarks about FORTH for C-Programmers", just 2 pages. Please find it attached, a PDF version and an editable one (ODF), someone may want to add something or correct mistakes.

RE: FORTH, unbearable, impossible? - a remark - Added by JohnO about 2 months ago

Thank you for your document Rolf.

    (1-4/4)