Benutzer-Werkzeuge

Webseiten-Werkzeuge


words:cls

cls

Ein Hilfe die ich gerne benutze wenn neuer Forth Code interaktiv ausgetestet wird.

: cls  ( x0 .. xn -- ) \ clear stack
  depth 0= IF ( noop) ELSE  depth 0 do drop loop THEN ;

Ein andere Variante ist diese:

: CLEAR  ( i*x -- )  \ clear stack  
  DEPTH 0 ?DO DROP LOOP ;

Wil Baden formulierte das einmal so: „CLEAR has also been used to clear the screen, clear a variable or structure, and other similar uses. It's use is almost certain to cause confusion to someone. Save it for a temporary debug.“ (Quelle)

Und fuhr dann fort: „The oldest debug tool I use is .. .“

: ..  ( i*x -- )
   DEPTH IF  .S  DEPTH 0 DO DROP LOOP  THEN ;

„This is the only way I would ever clear the stack.“

words/cls.txt · Zuletzt geändert: 2010-12-29 18:12 von 127.0.0.1