Opened 14 years ago
Closed 13 years ago
#300 closed enhancement (fixed)
allow reading without "hanging"
Reported by: | felix winkelmann | Owned by: | |
---|---|---|---|
Priority: | not urgent at all | Milestone: | |
Component: | core libraries | Version: | 4.5.x |
Keywords: | read-string no-hang | Cc: | |
Estimated difficulty: |
Description
(suggested by Alejandro)
It would be nice to have a "read as much of input as is currently available" type of read-string[!]
, say,
(read-string/no-hang NUM [PORT]) -> STRING (may be shorter than NUM)
(read-string!/no-hang NUM STRING [PORT [START]]) -> NUM'
This could probably be implemented using another port method, defaulting to char-ready?
+ read-char
.
Change History (4)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Older versions of chicken will raise an error when providing the read-buffered argument to make-input-port, and we cannot know when it is safe to do so. Would you mind adding some sort of feature identifier or other way to determine when read-buffered is a legal optional argument? This would help when create advanced custom ports.
comment:3 Changed 13 years ago by
Priority: | minor → not urgent at all |
---|
We can not add a feature-identifier for each and every enhancement made in the core libraries (there already are too many defined anyway). I suggest checking the chicken version or something like that, which is ugly but scales somewhat better.
I'd like to close this ticket and ignore the problem until someone complains.
I have added a (currently undocumented) procedure that may be helpful:
(read-buffered [PORT]) -> STRING
This returns any currently buffered input from the given port, or "" if nothing is buffered or the port does not support buffering.