Er...not quite. >IN is a variable which tells where the interpreter is in the current line. It doesn't have anything to do with KEY?, which returns a flag telling whether keyboard input is available. So 0 >IN ! resets the interpreter to the beginning of the line, and KEY? 0= IF ... THEN says "do this if no key has been pressed."
No, it's just for use interactively. Maybe as a debugging aid or something? Probably just a cute trick.
Well...you could put it in another definition, but it's not a compiled looping construct, it would just cause that word to behave like many. That is, when it is interpreted it would send the interpreter back to the beginning of the line. And of course it wouldn't have any effect until the word returns, so it wouldn't (usually) matter where in the definition you put it. Here's a lousy example: :-)
: count-up dup . many cr 1+ ;
17 ( need a line-break here; you don't want to do 17 every time ) count-up
Comments 3
Reply
(The comment has been removed)
Reply
(The comment has been removed)
No, it's just for use interactively. Maybe as a debugging aid or something? Probably just a cute trick.
Well...you could put it in another definition, but it's not a compiled looping construct, it would just cause that word to behave like many. That is, when it is interpreted it would send the interpreter back to the beginning of the line. And of course it wouldn't have any effect until the word returns, so it wouldn't (usually) matter where in the definition you put it. Here's a lousy example: :-)
: count-up dup . many cr 1+ ;
17 ( need a line-break here; you don't want to do 17 every time )
count-up
18
19
20
... until you press a key
--Josh
Reply
Leave a comment