Re: Cases where Forth seems a little clunky
- From: Yvo.Zoer@xxxxxxxxx
- Date: 10 May 2007 08:44:04 -0700
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...
.
- References:
- Cases where Forth seems a little clunky
- From: vandyswa
- Re: Cases where Forth seems a little clunky
- From: John Doty
- Re: Cases where Forth seems a little clunky
- From: Andreas Kochenburger
- Re: Cases where Forth seems a little clunky
- From: John Doty
- Re: Cases where Forth seems a little clunky
- From: Andreas Kochenburger
- Re: Cases where Forth seems a little clunky
- From: Jean-François Michaud
- Re: Cases where Forth seems a little clunky
- From: Yvo . Zoer
- Cases where Forth seems a little clunky
- Prev by Date: Re: Cases where Forth seems a little clunky
- Next by Date: Re: Cases where Forth seems a little clunky
- Previous by thread: Re: Cases where Forth seems a little clunky
- Next by thread: Re: Cases where Forth seems a little clunky
- Index(es):
Relevant Pages
|