
Am 19.03.2017 um 00:08 schrieb Brandon Allbery:
On Sat, Mar 18, 2017 at 6:51 PM, Ben Franksen
wrote: What exactly is meant here with "conflate"?
Confusing two distinct mechanisms that appear on the surface to be similar. See below for why this is an inappropriate conflation.
My question was meant as "technically, how exactly do they do the conflation". So IIUC you say that when I use hSetBuffering, nowadays it does /more/ then just change buffering mode, it /also/ (sometimes) reconfigures the terminal. And this is the reason it can be used for the purpose of the OP but it is a bad idea to rely on that because that 'feature' was a bad idea in the first place.
When you turn off buffering for stdin, then of course backspace cannot work. That should be clear.
Except that is not true anywhere but recent versions of ghc's runtime, and (specifically because they use readline or editline) things like Python's REPL. Try it in a simple C program.
I was not aware of that. I just tried it in C and it turns out you are right.
Buffering means the program reads in chunks instead of character at a time. This is an attribute of a program, specifically of whatever I/O library it is using.
Of course.
It does not include line editing (you don't generally want to interpret a backspace in a text file you are reading. You *certainly* don't want to interpret control-C or control-D).
Hm, no, probably not.
Things like backspace *do not live in the program*, unless you are using a library like readline or editline.
As long as you leave control over these things to the terminal, yes. But what if your program wants to control that itself? E.g. react to keystrokes, rather than edited lines, as the OP seemed to want? I guess what I want to say/ask is: if it is a bad idea to conflate terminal configuration and buffering (and i agree it is: it mis-educated me to think this is how it works in Unix), could and should not Haskell still offer a simple and portable way to configure this (explicitly) from inside the program? Should I import haskeline just to turn off the terminal's line editing mode? Cheers Ben