streaming redux

Steven Schveighoffer schveiguy at yahoo.com
Wed Dec 29 08:02:23 PST 2010


On Wed, 29 Dec 2010 01:01:09 -0500, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 12/28/10 10:57 AM, SHOO wrote:
>> (2010/12/28 16:02), Andrei Alexandrescu wrote:
>>> I've put together over the past days an embryonic streaming interface.
>>> It separates transport from formatting, input from output, and buffered
>>> from unbuffered operation.
>>>
>>> http://erdani.com/d/phobos/std_stream2.html
>>>
>>> There are a number of questions interspersed. It would be great to  
>>> start
>>> a discussion using that design as a baseline. Please voice any related
>>> thoughts - thanks!
>>>
>>>
>>> Andrei
>>
>> I hope that this argument grows warm. For Phobos, the I/O is a very
>> important component.
>>
>>
>> I have some doubt about this interface.
>>
>> 1.
>> There seems to be it on the basis of the deriving.
>> In comparison with current std.stream, what will the advantage be?
>
> With dynamically polymorphic interface, client code need not be  
> templated in order to accommodate any implementation of the interface.  
> Also, there is more opportunity for layering interface implemetations  
> during run time.

Consider this scenario:

stdout is currently implemented via C's FILE * to allow interleaving of C  
output and D output.  However, FILE * has some limitations that may hinder  
performance.  If you don't care about interleaving C and D I/O, you could  
replace stdout with a D-based output stream to achieve higher  
performance.  But this is only possible if stdout is *runtime* switchable,  
which means both the C-based stdout and the D-based stdout have a common  
base and implement polymorphism.

I think the right call in I/O is to use interfaces/classes and not  
compile-time interfaces.

-Steve


More information about the Digitalmars-d mailing list