stdio line-streaming revisited

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Wed Mar 28 23:40:08 PDT 2007


Bill Baxter wrote:
> kris wrote:
>> Andrei Alexandrescu (See Website For Email) wrote:
> 
>> - Tango is for D programmers; not C programmers.
> 
> D programmers sometimes like to call 3rd party code written in other 
> languages, and pretty much any interop in D has to happen via C 
> compatibility.  E.g. pyD.  So I'm guessing if my D code calls on some 
> Python code that prints to the console that somewhere down the line that 
> eventually ends up on C's stdout.  I could be wrong, but at least that's 
> why I *think* Andrei and Walter keep saying that C compatibility is 
> important.

Yes.

> Andrei -- by "compatibility" does that mean if I rebind stdio/stdout to 
> something different that both D and C's output go to the new place?  Or 
> is it still necessary to rebind them individually?  I did this once for 
> some legacy code in C++, and found that I had to rebind 3 things: the C 
> streams, the C++ old-style streams from <iostream.h> (was under MSVC 6), 
> and the new-style C++ streams from <iostream>.    And then I had to do 
> the interleaving myself, which didn't really work (because all the 
> streams were just writing to output buffers individually).  If what 
> you're talking about with compatibility would avoid that kind mess, that 
> is certainly be a good thing.

Exactly. I'm hoping to save the D community from the iostreams mess, 
which requires the programmer to deal with two (or three as in your 
example) incompatible APIs. It's iostreams' amazing counterperformance 
that they managed to cut the speed so effectively in the process :o).

I think a wise thing that Tango could do is to offer a 
backward-compatible stdio, and a high-performance I/O class using the 
latest and greatest from each I/O (zero-copy (see 
http://research.sun.com/techrep/1995/abstract-39.html), asynchronous, 
threaded, kernelized, teleported, you name it).

The main desideratum is that fast/incompatible I/O is opt-in, not lock-in.


Andrei



More information about the Digitalmars-d mailing list