Skip to content

Conversation

@rmolives
Copy link
Contributor

@rmolives rmolives commented Aug 5, 2025

It will appear when using stream transmission:

rmolives@debian:~$ scheme --script <(echo "(display (+ 2 3))")
Exception in port-position: failed on #<binary input port /dev/fd/63>: illegal seek

Related issues are #901

So we changed some codes to make it support the same operation as Python.

@mflatt
Copy link
Contributor

mflatt commented Aug 13, 2025

Thanks for the PR, and this is certainly a problem worth solving, but I'm doubtful of the approach of catching an exception and then reading differently. I can't point to something that is both likely and that would go wrong, but catching an error and assuming that it means a non-seekable file seems indirect, and indirect things can have unexpected consequences. I also worry about reading in a potentially large input before parsing.

I think it's probably better to just avoid port-position by ensuring that unget-u8 can work to put back up to three bytes. In fact, I think unget-u8 will already work here if the file-buffer length is parameterized to be at least 3, even though putting back multiple bytes is not allowed by the specification of unget-u8. That it turns out to work is internal implementation detail, but it would be fair to rely on that internal detail in this internal function.

@mflatt
Copy link
Contributor

mflatt commented Aug 13, 2025

Well, I see that $source-file-descriptor is also an obstacle. Maybe there's not going to be an approach that avoids reading all of the input.

@rmolives rmolives closed this by deleting the head repository Aug 13, 2025
mflatt added a commit to mflatt/ChezScheme that referenced this pull request Aug 13, 2025
mflatt added a commit to mflatt/ChezScheme that referenced this pull request Aug 13, 2025
mflatt added a commit to mflatt/ChezScheme that referenced this pull request Aug 13, 2025
mflatt added a commit that referenced this pull request Sep 1, 2025
mflatt added a commit to racket/racket that referenced this pull request Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants