www.digitalmars.com         C & C++   DMDScript  

D - Breaking down std.stream

reply Chris Sauls <ibisbasenji yahoo.com> writes:
It occurs to me that the std.stream module ought to be broken down into 
its component parts... ie into a series of modules like:
	std.stream(.stream?)
	std.stream.file
	std.stream.memory
	std.stream.slice

Thoughts?

C. Sauls
Invironz
Dec 04 2003
parent reply "Julio César Carrascal Urquijo" <adnoctum phreaker.net> writes:
Agreed, and maybe add an IStream interface.

There are other problems with the stream module, like using exceptions to
flag EOF (every file has an end, it isn't an exceptional circumstance).



"Chris Sauls" <ibisbasenji yahoo.com> wrote in message
news:bqns2v$13i1$1 digitaldaemon.com...
 It occurs to me that the std.stream module ought to be broken down into
 its component parts... ie into a series of modules like:
 std.stream(.stream?)
 std.stream.file
 std.stream.memory
 std.stream.slice

 Thoughts?

 C. Sauls
 Invironz
Dec 06 2003
parent reply "Charles Sanders" <sanders-consulting comcast.net> writes:
Ouch!  where ( what file ) is this ?

C


"Julio César Carrascal Urquijo" <adnoctum phreaker.net> wrote in message
news:bqtqnr$1471$1 digitaldaemon.com...
 Agreed, and maybe add an IStream interface.

 There are other problems with the stream module, like using exceptions to
 flag EOF (every file has an end, it isn't an exceptional circumstance).



 "Chris Sauls" <ibisbasenji yahoo.com> wrote in message
 news:bqns2v$13i1$1 digitaldaemon.com...
 It occurs to me that the std.stream module ought to be broken down into
 its component parts... ie into a series of modules like:
 std.stream(.stream?)
 std.stream.file
 std.stream.memory
 std.stream.slice

 Thoughts?

 C. Sauls
 Invironz
Dec 07 2003
parent "Julio César Carrascal Urquijo" <adnoctum phreaker.net> writes:
"Charles Sanders" <sanders-consulting comcast.net> wrote in message
news:br07nl$1s1r$1 digitaldaemon.com...
 Ouch!  where ( what file ) is this ?

 C
In the std.stream module there are lots of sections that look like this: try { --cut--cut-- } catch (ReadError e) { // either this is end of stream, which is okay, // or something bad occured while reading if (!eof()) throw e; } And that eof() call it's really expensive (Executes at least four seeks on the file). The following is from the d2html.d sample in the DMD distribution. // the main part is wrapped into try..catch block because // when end of file is reached, an exception is raised; // so we can omit any checks for EOF inside this block... try { --cut--cut-- } // if end of file is reached and we try to read something // with typed read(), a ReadError is thrown; in our case, // this means that job is successfully done catch (ReadError e) { // write HTML footer dst.writeLine("</code></pre></body></html>"); } The tendency is to catch ReadError and discard any real error as end of file.
Dec 08 2003