-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternative to read-line #49
Comments
What's the difference between |
I think it's a little more complicated, with an extra value return value when the buffer is too short to hold a full line. And there's also simple-stream-read-line, which uses the buffer except when the line is too long, in which case it allocates a new string. |
OK - I've found the documentation of it at https://franz.com/support/documentation/current/doc/operators/excl/read-line-into.htm How can this be implemented without implementation support in an optimized way/without reading char by char? If we try to read a whole buffer of characters at once, it's possible that we'll overshoot the newline, at which point we will need to unread multiple characters, which is impossible in portable CL when working with arbitrary streams. |
That's a good question, and why this is an open issue. On the other hand, reading character by character may not be that inefficient, assuming the implementation buffers reads internally. And there's always the possibility of a Gray stream (although in that case the performance benefits might be lost). |
In the event where we can both provide a Gray stream that's capable of buffering reads and unreading multiple chars at once and having a specialized But, yes, this sounds like a question for implementations themselves - is there any API for their default streams to unread whole chunks of data, which would make an efficient |
You can always "unread" multiple character using
|
The issue is you can't do that outside a function call. If you do |
It would be nice to have an alternative to read-line, along the lines of read-line-into.
If it is too clumsy to be practical to be used directly it could still be wrapped into a nice Iterate driver.
The text was updated successfully, but these errors were encountered: