Re: Starting Forth, starting out.



Trey Boudreau wrote:

On 2006-01-05, Jerry Avins <jya@xxxxxxxx> wrote:

John Doty wrote:

Jerry Avins wrote:


For one reason, the phrase DEPTH DROP so clearly amounts to a no-op

> ...

Depends on your dialect. In LSE "depth drop iterate" clears the stack! Simpler (but surely stranger ;-) than ANS Forth.



Strange indeed!

start with ( x y z )
DEPTH      ( x y z depth )
DROP       ( x y z )
ITERATE    ?????


Given the descriptions he's provided recently, I'd guess:

ITERATE - super-immediate (via one-token look-ahead).  Execute the
		  compilation buffer (or perhaps just the previous token) TOS
		  times.

The hyper-reductionist style of thought required to navigate the interpreter/compiler maze in traditional Forth isn't required for ordinary programming in LSE, so the doc just says:


n action iterate	(perform action n times)

Nor does it "execute the compile buffer". The definition:

repent : depth drop iterate

works just like the command "depth drop iterate". Both implementations so far (Bob's old one and my modern one) are merely IMMEDIATE, but that reflects the fact that they are both ITC, so that at compile time "iterate" can just pick up the cell that the compiler made of "drop" and move it into the loop it compiles.

I don't know why Bob did it this way, and I'm seriously considering changing it to:

n iterate action	(perform action n times)

---
John Doty, Noqsi Aerospace, Ltd.
---
His diagnosis of the hostility ... reflects the willful blindness of the invader who assures himself that the natives are only made unfriendly by some other provocation than his own. -Barbara W. Tuchman
.




Relevant Pages

  • Re: Starting Forth, starting out.
    ... I would associate ITERATE with an iterator over integers, ... ANS Forth, so that the user can share the benefits of the ANS Forth source ... The main problem bogs down to non-immediate parsing words that alter the ... and not break the compilation flow. ...
    (comp.lang.forth)
  • Re: foreach and stack, iterating from the bottom-up?
    ... precise) and I was a bit surprised that it seems to iterate from the ... bottom up. ... Stack extends Vector, Vector implements List, List.iterator has very ... Also, generally you don't "Iterate" stacks, you push onto and pop from ...
    (comp.lang.java.programmer)
  • Re: pop method question
    ... A stack is defined to be an "ordered" list data ... does anyone know why the python core has this pop method ... implemented for a dictionary type? ... # can't iterate over the dictionary directly! ...
    (comp.lang.python)
  • Re: foreach and stack, iterating from the bottom-up?
    ... precise) and I was a bit surprised that it seems to iterate from the ... bottom up. ... Most likely an unwelcome consequence of implementing Stack ... Stack would be at the high-index end of the Vector (to avoid ...
    (comp.lang.java.programmer)
  • Re: How to get stack from every thread when doing crash dump?
    ... On Jun 23, 2005, at 5:39 PM, Howard wrote: ... >> You can iterate over all the threads. ... >> and for each thread dump the stack, ...
    (freebsd-arch)