digitalmars.D.learn - Creating stream from stdout
- Mandeep (6/6) Apr 23 2011 I have created a stream from stdout by using the following method.
- =?ISO-8859-1?Q?Ali_=C7ehreli?= (6/12) Apr 23 2011 Consider streams gone from D. They are deprecated in favor of a "range"
- Jonathan M Davis (16/32) Apr 23 2011 That's not quite true. You've misunderstood.
- =?ISO-8859-1?Q?Ali_=C7ehreli?= (26/57) Apr 23 2011 Which of my three statements are you referring to? Your use of vague
- Jonathan M Davis (10/97) Apr 23 2011 stdin and stdio are _not_ streams. They're instances of std.stdio, and t...
- =?ISO-8859-1?Q?Ali_=C7ehreli?= (15/18) Apr 24 2011 away.
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
Apr 23 2011
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 MandeepConsider 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 Ali
Apr 23 2011
On 04/23/2011 04:23 AM, Mandeep wrote:That's not quite true. You've misunderstood. 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. 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. - Jonathan M DavisI 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 MandeepConsider 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
Apr 23 2011
On 04/23/2011 04:32 PM, Jonathan M Davis wrote:achieveOn 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 toWhich of my three statements are you referring to? Your use of vague words like "that" doesn't help.That's not quite true. You've misunderstood.this without FP. Thanks& Regards MandeepConsider 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=1407357Ranges are heavily used in Phobos, and most modules use them and aregoing touse 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 otherissues withit that make it so that it's considered deficient anyway, but Ihaven't reallyused 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 replacedwith anew module (possibly called std.stream) which _does_ use ranges.However, thatnew module has not been completed or even completely designed as faras itsbasic API goes. So, std.stream as it stands is going away. None of the current I/Ostreamingin Phobos will be sticking around in the long run. However, it will be replaced with new I/O streaming functionality which is range-based atsomepoint in the future. As the new stuff is nowhere near complete, theold stuffis 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
Apr 23 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.stdin and stdio are _not_ streams. They're instances of std.stdio, and they are _not_ going away. As far as I know, nothing in std.stdio is going away. std.stream as it stands (which _does_ using streaming I/O) _is_ going away. It will be replaced by another module which uses range-based streaming I/O. You were saying that streams will be going away in favor of ranges, which is not true. While it makes a lot of sense to treat streams as ranges, they are definitely different concepts, and neither will be replacing the other. The current stream API in std.stream will be going away in favor of a new, range- based stream API. But streams themselves as a concept will not be going away. - Jonathan M Davis
Apr 23 2011
On 04/23/2011 10:37 PM, Jonathan M Davis wrote:stdin and stdio are _not_ streams.How do you define "stream"? stdin and stdout are streams.They're instances of std.stdio, and they are _not_ going away. As far as I know, nothing in std.stdio is goingaway. That's correct. I've been inconsistent: When I said that D's streams were going away, I meant std.stream and std.cstream. Regardless, nothing can change the fact that just like C's stdin and stdout, D's stdin and stdout are streams. $ man stdin | head STDIN(3) Linux Programmer's Manual STDIN(3) NAME stdin, stdout, stderr - standard I/O streams SYNOPSIS #include <stdio.h> Ali
Apr 24 2011