Re: Cases where Forth seems a little clunky



On 10 May, 08:41, Yvo.Z...@xxxxxxxxx wrote:
On 10 May, 08:19, Jean-François Michaud <come...@xxxxxxxxxxx> wrote:





On May 9, 11:31 pm, "Andreas Kochenburger" <a...@xxxxxxxxxx> wrote:

"John Doty" <j...@xxxxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitragnews:M-ydnZjcSLPJxN_bnZ2dnUVZ_qGjnZ2d@xxxxxxxxxxxxxxxx

Andreas Kochenburger wrote:

It's an interesting example, however, to me it seems to replace the
complexity of stack shuffling by the complexity of exotic operators. A
KISS solution has the charm of reflecting the natural motion when you
move a row of stones from one place to another. Think like a child:

: COPY { src dest count -- }
count 0 ?do
src @ dest !
1 +to src
1 +to dest
loop ;

All kinds of exotica here: ?do, +to, locals, block structure...

Incidently yesterday evening I showed your first posting to my younger son
who has an advanced IT course at school. It took some while before he
understood your notation, and then just said "that's not good, it's ugly and
unnecessarily difficult".

Clunky.

Andreas

That doesn't mean much Andreas, especially if it's his first contact
with Forth derived languages under RPN.

Also, it's not ugly, it's convoluted. It took me about 10 second to
understand (I had a headstart though, I'm familiar with Forthlike
languages and RPN processing).

I'm also somewhat fresh out of school (CS) and I have a different
perspective on the subject. The notation is pretty straightforward.
What your guy had trouble with is probably the exotic nature of Forth
and RPN all at the same time. Being used to seeing taught language
which aren't RPN by nature and not having to think about the stack is
the norm in high level languages. Languages are now designed so that
coders don't have to think about the hardware at all. It still makes
me laugh thinking that a VERY good, advanced Java coder I know
completely tripped out when I Hex dumped an XML file to look at some
problems we were having.

In it's context, I find John's definition rather elegant, simple,
although I don't personally like using variables, I can see it making
this exercise very simple.

I like HumptyDumpty's decomposition the most. His factors are simple
and useful. Everything is straightforward and clean to understand at a
glance; no effort required. Truthfully, it took me about 3 seconds for
that one (I'm lying a bit, I double checked the loop more thoroughly a
second time for an additional 2 seconds ;-)).

Regards
Jean-Francois Michaud- Hide quoted text -

- Show quoted text -

Long time lurker, first time poster :-) Maybe I'm missing the obvious
but, how about changing it *slightly* to:

: bcopy ( dst src count -- )
over + swap do
i c@ over c! 1+
loop ;

using src as an address counter to reduce the inner loop to 5
instructions.

Thoughts?- Hide quoted text -

- Show quoted text -

Well, that'll teach me to not read EVERY post. Already been mentioned
AND I forgot to DROP the last item on the stack.. Hmmm...

.



Relevant Pages

  • Re: Cases where Forth seems a little clunky
    ... complexity of stack shuffling by the complexity of exotic operators. ... with Forth derived languages under RPN. ... that one (I'm lying a bit, I double checked the loop more thoroughly a ...
    (comp.lang.forth)
  • 50G new user documentation
    ... 7.The Main part of the screen is called the stack. ... Using RPN ... 18.You may prefer working in algebraic mode. ... LEFT DOWN to highlight the 14. ...
    (comp.sys.hp48)
  • Re: 50G new user documentation
    ... 7.The Main part of the screen is called the stack. ... Using RPN ... 18.You may prefer working in algebraic mode. ... LEFT DOWN to highlight the 14. ...
    (comp.sys.hp48)
  • Re: modularity... (was: Re: Looking for real world examples to explain the difference between proced
    ... the most terrible problem I have found though for RPN, ... boolean expression to identify the minimum set of those products. ... The key to the linear time solution was converting the algebraic boolean ... this may involve flushing the stack to memory, ...
    (comp.object)
  • Re: Forth tutorial like Ketmans
    ... Forth is not like the other languages you have learned. ... code didn't have a single stack comment. ... such a visualization facility would not be very great for this ... Consider the case of visualizing a sort. ...
    (comp.lang.forth)