digitalmars.D - Stdio.write/writeln and flushing
- Somebody (13/13) Sep 08 2016 If i write something like:
- rikki cattermole (4/16) Sep 08 2016 Same problem with Poderosa (terminal emulator which supports Cygwin) its...
- Somebody (6/9) Sep 08 2016 I think you're right... I think half of the command line
- Steven Schveighoffer (15/27) Sep 08 2016 write and writeln depend on the behavior of FILE * for flushing, there
- Somebody (6/21) Sep 09 2016 Ah, good to know an alternative way, I thought just about
If i write something like: writeln("what to do?"); switch(readln[0 .. $ - 1]) { //.. } writeln("bye"); ...that works just as it should at Windows, started from a command prompt. However, if I run it from GNU Emacs, I have to manually flush the output after each time I do it before taking input, or else the output does not show when it should. I wonder if write(...) and writeln(...) should automatically flush, to enhance portability? Of course, I may be issing missing something?
Sep 08 2016
On 08/09/2016 8:53 PM, Somebody wrote:If i write something like: writeln("what to do?"); switch(readln[0 .. $ - 1]) { //.. } writeln("bye"); ...that works just as it should at Windows, started from a command prompt. However, if I run it from GNU Emacs, I have to manually flush the output after each time I do it before taking input, or else the output does not show when it should. I wonder if write(...) and writeln(...) should automatically flush, to enhance portability? Of course, I may be issing missing something?Same problem with Poderosa (terminal emulator which supports Cygwin) its at fault of the software which is client of the pipe. Phobos is doing what it should be doing.
Sep 08 2016
On Thursday, 8 September 2016 at 08:56:43 UTC, rikki cattermole wrote:Same problem with Poderosa (terminal emulator which supports Cygwin) its at fault of the software which is client of the pipe. Phobos is doing what it should be doing.I think you're right... I think half of the command line applications wouldn't run anyway with such a shell regardless what Phobos does. Probably there is a way to configure Emacs otherwise, gotta search out...
Sep 08 2016
On 9/8/16 4:53 AM, Somebody wrote:If i write something like: writeln("what to do?"); switch(readln[0 .. $ - 1]) { //.. } writeln("bye"); ....that works just as it should at Windows, started from a command prompt. However, if I run it from GNU Emacs, I have to manually flush the output after each time I do it before taking input, or else the output does not show when it should. I wonder if write(...) and writeln(...) should automatically flush, to enhance portability? Of course, I may be issing missing something?write and writeln depend on the behavior of FILE * for flushing, there is no specific flush. Note that FILE * examines the file descriptor and if it is detected as an interactive descriptor, flush is done every newline. If not, then flush is only done when the buffer is full. This is standard behavior forever, and is done to avoid performance problems when piping the result of a command to a file, for instance (flushing is expensive). Your emacs "console" is not marked by the OS as interactive (or however it's detected by FILE *, implementation defined), therefore flush does not happen on newlines. If you want to force newline flushing, use parameter of _IOLBF. -Steve
Sep 08 2016
On Thursday, 8 September 2016 at 13:22:10 UTC, Steven Schveighoffer wrote:write and writeln depend on the behavior of FILE * for flushing, there is no specific flush. Note that FILE * examines the file descriptor and if it is detected as an interactive descriptor, flush is done every newline. If not, then flush is only done when the buffer is full. This is standard behavior forever, and is done to avoid performance problems when piping the result of a command to a file, for instance (flushing is expensive). Your emacs "console" is not marked by the OS as interactive (or however it's detected by FILE *, implementation defined), therefore flush does not happen on newlines. If you want to force newline flushing, use mode parameter of _IOLBF. -SteveAh, good to know an alternative way, I thought just about redefining write(...) and writeln(...) locally. Thanks. I guess the real answer still is to configure OS/Emacs, as apparent when I did dub.init with Emacs.
Sep 09 2016