comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <no.spam@no.spam.com>
Subject: Re: I/O streaming with custom data transport
Date: Wed, 22 Nov 2006 10:21:02 +0100
Date: 2006-11-22T10:21:02+01:00	[thread overview]
Message-ID: <ek14pu$k4v$1@cernne03.cern.ch> (raw)
In-Reply-To: <17ayrefpaw84a$.2qy8q0wbzzwk.dlg@40tude.net>

Dmitry A. Kazakov wrote:

>> In C++ the IOStreams library allows to vary the behaviour of the stream 
>> by decoupling formatting from data buffering and transport to the 
>> physical device, which are in turn strategies for the stream object. 
>> This means that having millions of functions like this:
>>
>> void foo(ostream &s)
>> {
>>      s << "Hello";
>>      s << someObject;
>>      s << someOtherObject;
>>      // ...
>> }
>>
>> (and *there are* millions of functions like this)
> 
> Alas, because it is a poor design based on ad-hoc polymorphism. All these
> millions are overloaded.

I don't understand. The focus here is on foo - which represents the set 
of functions that can use the stream without really caring what the 
stream is.

> In Ada it is exactly same. Consider:
> 
>    Put (S : in out My_Root_Stream; X : String);
>    Put (S : in out My_Root_Stream; X : SomeObject);
>    ...
> 
> An alternative design (still non-MD) is:
> 
>    Put (S : in out Root_Stream'Class; X : String);
>    Put (S : in out Root_Stream'Class; X : SomeObject);
>    ...
> 
> This achieves what you want. You can implement I/O on an object type like
> String using some common class-wide functionality of streams and then
> re-use it over all possible streams.

OK, now I see - there is a bit of misunderstanding. I'm not asking about 
how to provide new formatting, but rather how to provide new data 
transport. The practical intention is that I want to write some code 
that will be reused both with file streams and with network streams (for 
example).

Please see the example code in my reply to Alex, I think I've found the 
functionality that I'm looking for.

-- 
Maciej Sobczak : http://www.msobczak.com/
Programming    : http://www.msobczak.com/prog/



  reply	other threads:[~2006-11-22  9:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-21 15:11 I/O streaming with custom data transport Maciej Sobczak
2006-11-21 15:28 ` gautier_niouzes
2006-11-21 17:51 ` Alex R. Mosteo
2006-11-22  9:16   ` Maciej Sobczak
2006-11-22 10:01     ` Alex R. Mosteo
2006-11-22 10:39       ` Maciej Sobczak
2006-11-22 16:06         ` Dmitry A. Kazakov
2006-11-22 16:30         ` Alex R. Mosteo
2006-11-23  5:48         ` Simon Wright
2006-11-22 13:50     ` Robert A Duff
2006-11-22 14:37       ` Maciej Sobczak
2006-11-22 16:11         ` Georg Bauhaus
2006-11-21 19:02 ` Dmitry A. Kazakov
2006-11-22  9:21   ` Maciej Sobczak [this message]
2006-11-22 10:31     ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox