shirok / Gauche

Scheme Scripting Engine
https://practical-scheme.net/gauche
Other
811 stars 81 forks source link

Fundamental fix of peek/read interference #188

Open shirok opened 8 years ago

shirok commented 8 years ago

Scm_Peekc currently ignores scratch buffer. GETC_SCRATCH still has issues with keeping remaining octets in scratch buffer.

Related: https://github.com/shirok/Gauche/pull/186

shkmr commented 8 years ago

In your comment in #186, you suggest putting spectial mark on char object when invalid byte sequence is encountered.

Would it be possible just raising an error in that case? (possibly with an API to get the bytes in question.)

shirok commented 8 years ago

That could be one solution. Invalid byte sequences could throw an error in CES conversion routine anyway, so wrapping invalid octet as a special kind of char is at most an unreliable abstraction (meaning, you can't count on it everywhere). My concern is that occasionally you do encounter unexpected data, and sometimes throwing an error is inconvenient. But probably a flaky abstraction won't do much good.