The best way to get all available stuff from textual port I found so far is:
(define (read-all-chars-as-string port)
(let loop ((chars '()))
(if (char-ready? port)
(loop (cons (read-char port) chars))
(reverse-list->string chars))))
The best way to get all available stuff from textual port I found so far is: 5 comments
@otterz yes and it's exactly what I want. I want to read everything available at the moment to start processing what is already came to the pipe. There is another function, get-string-all from (ice-9 textual-ports), which looks for EOF instead and thus blocks until everything will arrive to the pipe. @ramin_hal9001 @otterz Sounds very reasonable to me! Thank you for the idea, I guess I will use it in the implementation :)
|
@abcdw neat! short and very readable. wouldn't "char-ready?" also return #f in cases other than EOF though?