[m-users.] Coupling stdout and stderr

Volker Wysk post at volker-wysk.de
Wed Mar 15 21:04:25 AEDT 2023


Am Mittwoch, dem 15.03.2023 um 14:12 +1100 schrieb Julien Fischer:
> Hi Volker,
> 
> On Mon, 13 Mar 2023, Volker Wysk wrote:
> 
> > In C++ (and Haskell, I think) there's a feature which causes stdout to be
> > flushed before writing something to stderr. I'm not sure how this is called.
> > This way, the output on both streams occurs in the right order. Arbitrary
> > streams can be coupled that way.
> 
> In C++ you can tie an istream to an ostream using the tie() function. Is
> that what you were thinking of? 

Yes.

> It wouldn't help in this case because
> cerr and cout are both ostreams.

Yes, I was mistaken. But it would still make sense to tie stdout to stderr,
wouldn't it?

> 
> > I've looked through the io library, but couldn't find anything like that.
> > When you have a lot of output on stdout and then output something on stderr,
> > the order gets messed up. You have to manually flash stdout before writing
> > to stderr.
> 
> You could probably write something using the stdlib's stream interface
> that did that.

I'll take a look next time I need it.

Thanks

Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20230315/3755fad4/attachment.sig>


More information about the users mailing list