Re: Cases where Forth seems a little clunky



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?





.



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. ...
    (comp.lang.forth)
  • 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)
  • Re: Cases where Forth seems a little clunky
    ... complexity of stack shuffling by the complexity of exotic operators. ... with Forth derived languages under RPN. ...
    (comp.lang.forth)
  • Re: How to copy multi object array contents into single object arrays?
    ... languages most recognizable for blocks delimited with curly braces. ... hoisting the loop bound.) ... As to the efficiency claims, ... I see differences in integer array look-ups, ...
    (comp.lang.javascript)
  • Re: PCL trash
    ... whether there are some social reasons, ... the equivalents of LOOP? ... dialect of CL, and not directed toward other languages, or other ... How is Scheme a close dialect of CL? ...
    (comp.lang.lisp)