Creating stream from stdout

Ali Çehreli acehreli at yahoo.com
Sat Apr 23 22:12:01 PDT 2011


On 04/23/2011 04:32 PM, Jonathan M Davis wrote:
 >> On 04/23/2011 04:23 AM, Mandeep wrote:
 >>> I have created a stream from stdout by using the following method.
 >>>
 >>> new CFile(stdout.getFP(), FileMode.Out)
 >>>
 >>> It works but is this the correct way or is there a better way to 
achieve
 >>> this without FP.
 >>>
 >>> Thanks&  Regards
 >>> Mandeep
 >>
 >> Consider streams gone from D. They are deprecated in favor of a "range"
 >> interface. std.range and std.algorithm have examples of ranges that are
 >> first introduced in this article (with different names in Phobos):
 >>
 >>     http://www.informit.com/articles/printerfriendly.aspx?p=1407357
 >
 > That's not quite true. You've misunderstood.

Which of my three statements are you referring to? Your use of vague 
words like "that" doesn't help.

 > Ranges are heavily used in Phobos, and most modules use them and are 
going to
 > use them. std.stream is the current module for streaming I/O in Phobos.

What is "streaming I/O"? stdin and stdout are streaming I/O too. Do you 
consider them non-Phobos?

 > However, it is old and does _not_ use them. It probably has other 
issues with
 > it that make it so that it's considered deficient anyway, but I 
haven't really
 > used it much, so I'm not all that familiar with it. Regardless, because
 > std.stream is old and does not use streams, it's going to be replaced 
with a
 > new module (possibly called std.stream) which _does_ use ranges. 
However, that
 > new module has not been completed or even completely designed as far 
as its
 > basic API goes.
 >
 > So, std.stream as it stands is going away. None of the current I/O 
streaming
 > in Phobos will be sticking around in the long run. However, it will be
 > replaced with new I/O streaming functionality which is range-based at 
some
 > point in the future. As the new stuff is nowhere near complete, the 
old stuff
 > is still there, but eventually it won't be.

I read the above multiple times. Unfortunately I can't understand more 
than what I already knew.

Let me get back to my three statements:

1) Streams are gone from D. Since with "streams", I can only possibly 
mean what is already in D, I mean those streams are gone from D. I 
shouldn't need to disclaim that some module in the future may be related 
to streams.

2) Streams that are currently present in D are deprecated in favor of a 
new interface that will use ranges, or be ranges.

3) The seminal paper that I linked above is it.

Ali



More information about the Digitalmars-d-learn mailing list