gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] a dataflow / point-free perspective on Forth programming


From: Josh Grams
Subject: Re: [gforth] a dataflow / point-free perspective on Forth programming
Date: Sun, 7 Mar 2010 15:49:38 -0500
User-agent: Mutt/1.5.18 (2008-05-17)

>On Sun, Mar 7, 2010 at 9:43 AM, Anton Ertl
><address@hidden> wrote:
>
>> You ain't seen nothing yet.  Or, in other words, this is not an
>> example that would be considered as having a lot of stack dancing by
>> most Forth programmers.
>
>lol. That's what I'm seeing. And it perplexes me. I dont understand
>why someone would want to detract away from the basic dataflow with
>the mechanics of preparing arguments for the next word.
>
>I am trying to stay focused on the flow of data through operations and
>staring at a bunch of stack manipulations greatly inhibits that IMHO.

This is because you're new to the language.  When you get comfortable
enough with the stack, it no more detracts from the readability than
do the curly brackets, parentheses, and semicolons detract from the
readability of C.  It's all about what you're familiar with.

Here is a post from comp.lang.forth by Elizabeth Rather that I like,
about teaching beginning Forth:

http://groups.google.com/group/comp.lang.forth/msg/21f6437bd9e1ff9e

This one is less focused, but also has some good stuff about readability
and stack juggling:
http://groups.google.com/group/comp.lang.forth/msg/9600dae61973a255

>> Your rewrite appears to be an example of overfactoring.
>
>I love my rewrite (http://gist.github.com/323976). It reminds me of
>what I saw in "Thinking Forth"
>(http://www.forth.com/starting-forth/sf1/sf1.html)
>that excited me in the first place -
> : WASHER  WASH SPIN RINSE SPIN ;

Yes, but not everything in Forth looks like that.  You generally have at
least two levels.  You have to start with lower-level words, which
almost always have stack juggling.  But you try to design those in such
a way that they comprise a domain-specific language which allows you to
write the higher-level functions with minimal juggling.

Note also that that example reads and writes I/O ports (similar to
global variables) which helps it avoid stack manipulation.

Another relevant post from comp.lang.forth (about the washer example):
http://groups.google.com/group/comp.lang.forth/msg/2071dd5276b035f4


But I'd say that if you don't want to deal with low-level stuff like
stack juggling and memory allocation and how data structures are laid
out in memory, and if you want everything to be dynamic (avoiding global
variables and static memory allocation and so on), then Forth is
probably not the language for you.  Factor would be a better choice.

--Josh




reply via email to

[Prev in Thread] Current Thread [Next in Thread]