digitalmars.D.learn - GUI and non-GUI stream usage?
- Bill Baxter (10/10) Nov 17 2007 It seems all the dout, derr streams defined in std.cstream throw
- Stewart Gordon (11/18) Nov 18 2007 Annoying purely because you're not used to it, or for some other reason?
- Bill Baxter (12/29) Nov 18 2007 It's annoying because it makes it difficult to write programs and
- Bill Baxter (14/18) Nov 18 2007 Correction: I just realized that dout does *NOT* throw an exception, but...
- Kris (2/6) Nov 18 2007 Aye, it is
It seems all the dout, derr streams defined in std.cstream throw exceptions if they're unable to write their output. I find that unexpected and quite annoying. From my experience such IO stream classes for dealing with console IO always just ignore writes if there is no console attached. Is there a good reason for it to behave the way it does? Or should I file a bug on it? (And Tango folks -- does Stdout in Tango throw exceptions when there's no console?) --bb
Nov 17 2007
"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message news:fhnqbq$1dns$1 digitalmars.com...It seems all the dout, derr streams defined in std.cstream throw exceptions if they're unable to write their output. I find that unexpected and quite annoying. From my experience such IO stream classes for dealing with console IO always just ignore writes if there is no console attached.Annoying purely because you're not used to it, or for some other reason?Is there a good reason for it to behave the way it does? Or should I file a bug on it?It probably isn't a bug. If an application can't write to a file or external device when it needs to, it's a serious error. To suppress the error in the particular case where it's stdout or stderr you're writing to would be an inconsistency. Stewart. -- My e-mail address is valid but not my primary mailbox. Please keep replies on the 'group where everybody may benefit.
Nov 18 2007
Stewart Gordon wrote:"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message news:fhnqbq$1dns$1 digitalmars.com...It's annoying because it makes it difficult to write programs and libraries that can be used effectively either in a GUI or Console setting. And, yes, also because C++ doesn't act that way, and it's not documented clearly under CFile's docs, so I didn't expect it and others probably won't expect it either. Failing that, I guess if there's a way I can freopen stdout/stderr to /dev/null on Windows that will do it. I'll give that a try.It seems all the dout, derr streams defined in std.cstream throw exceptions if they're unable to write their output. I find that unexpected and quite annoying. From my experience such IO stream classes for dealing with console IO always just ignore writes if there is no console attached.Annoying purely because you're not used to it, or for some other reason?All I know is that cout in C++ doesn't generate an exception when writing to cout in a GUI app. I'm not sure how that happens or at what layer, but it doesn't. --bbIs there a good reason for it to behave the way it does? Or should I file a bug on it?It probably isn't a bug. If an application can't write to a file or external device when it needs to, it's a serious error. To suppress the error in the particular case where it's stdout or stderr you're writing to would be an inconsistency.
Nov 18 2007
Bill Baxter wrote:Correction: I just realized that dout does *NOT* throw an exception, but derr does. Whether exceptions should be thrown or not, that seems like inconsistent behavior to me.It seems all the dout, derr streams defined in std.cstream throw exceptions if they're unable to write their output.Failing that, I guess if there's a way I can freopen stdout/stderr to /dev/null on Windows that will do it. I'll give that a try.This does seem to work, for anyone who's interested. version (Windows) { std.c.stdio.freopen("Nul", "w", derr.file); } And the exceptions go away. In the bigger picture it would be nice if I could rebind dout and derr to a different Stream so that I could write a GUI StreamLogger class. From the rumblings I hear, I'm guessing that sort of thing is probably possible in Tango? --bb
Nov 18 2007
"Bill Baxter" <dnewsgroup billbaxter.com> wroteIn the bigger picture it would be nice if I could rebind dout and derr to a different Stream so that I could write a GUI StreamLogger class. From the rumblings I hear, I'm guessing that sort of thing is probably possible in Tango?Aye, it is
Nov 18 2007