I'm still working on a new Forth implementation...

Forth has a word `key` that gets one character from stdin. It
shouldn't wait for a newline to get the character. Is there any way to
implement this currently in PIR?

`$S0 = read 1` waits for the newline. If you turn off buffering for stdin:

 $P0 = getstdin
 stdin."setbuf"(0)
 $S0 = read 1

Parrot still waits for the newline, but the remaning characters aren't
picked up. So if you type "hello world\n" Parrot will take the "h" and
your console will get "ello world\n".

If it's not possible right now, I think it should be. The Forth
implementation needs it (though it's not exactly one of the target
languages). And I know people often want/expect Perl's getc to do the
same (I did -- and I see the question come up at Perl Monks
occasionally).

I don't how much work it'd take either, not knowing much C myself. It
looks like maybe it requires `getch` from conio.h (ported from DOS) or
curses (which I know dan is fond of ;)? And given the cross-platform
requirements of Parrot... is this even possible?

-- 
matt

Reply via email to