cisco / ChezScheme

Chez Scheme
Apache License 2.0
6.89k stars 983 forks source link

native eol style #844

Open olopierpa opened 1 week ago

olopierpa commented 1 week ago
> (native-eol-style)
none

This is fine if one only wants to read nl-style files. But it makes the default transcoder useless on windows as it makes any code using the default transcoder not able to read correctly native files.

And since there are functions like call-with-input-file which do not take a transcoder argument, it is impossible to use these functions to read native eol-style files on windows (I know that one can work around this by using Chez specific current-transcoder parameter, but let's suppose one wants to write portable code as much as reasonably possible.)

I'd call this a bug, but maybe there's a rationale for this behavior?

jltaylor-us commented 1 week ago

If one wants to write portable code as much as reasonably possible then one would always explicitly provide a transcoder, since the r6rs spec says that the default transcoder is implementation defined.

olopierpa commented 1 week ago

One supposes that the implementation defines it in a reasonable way. native-eol-style=none is not reasonable in any platform. It only half-works on unix by chance.

How do I provide my transcoder to call-with-input-file?

Having to rewrite my own version of call-with-input-file because the system supplied one is broken is not reasonable.

jltaylor-us commented 1 week ago

You already know how to provide a transcoder that will be used with call-with-input-file; you said so in the initial post. If you are asking how do that in some way that's portable to other scheme implementations then the answer is you can't, which means you can't use call-with-input-file in 100% portable code if your code is sensitive to anything influenced by the transcoder that the implementation uses.

I don't know what you could possibly mean by portable code except writing to a specification (presumably r6rs, the last complete specification). The behavior clearly conforms to the specification.

Just because you don't like the way it works doesn't mean it's broken. It's not like there aren't other reasonable interpretations of what the default behavior should be. I find it reasonable that the default behavior does not silently change a character stream of valid utf-8 encoded characters when they are read from a file on any platform, and that a program that writes characters out to a file produces byte-identical output on all platforms. That's not to say it can't change (although it is a significant backwards incompatibility), but calling it broken and appealing to portability concerns isn't going to get you anywhere.

olopierpa commented 1 week ago

I don't need to go anywhere.

Only, I wish I had not wasted the time I wasted chasing bugs caused by this perfectly fine and R6RS compliant behavior of Chez, and was trying to spare the pain to others.