Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 08, 2013 File IO: C# streams VS iterators? | ||||
---|---|---|---|---|
| ||||
I was watching a dconf talk about porting C# code to D. One thing that came up was there isn't anything like C# streams for D. Walter said he thinks iterators (unless I remember wrong) is superior. The speaker agreed but said it isn't a drop in replacement so that is an issue if you want to port. I haven't access file in D and i'm completely confused. What are iterators in regards to file IO? |
November 08, 2013 Re: File IO: C# streams VS iterators? | ||||
---|---|---|---|---|
| ||||
Posted in reply to DDD | On 11/8/13, 8:57, DDD wrote: > I was watching a dconf talk about porting C# code to D. One thing that > came up was there isn't anything like C# streams for D. Walter said he > thinks iterators (unless I remember wrong) is superior. The speaker > agreed but said it isn't a drop in replacement so that is an issue if > you want to port. > > I haven't access file in D and i'm completely confused. What are > iterators in regards to file IO? There are several ranges that can be used for file IO, for example http://dlang.org/phobos/std_stdio.html#.File.byChunk and http://dlang.org/phobos/std_stdio.html#.File.byLine . C# Stream has no such capability, which is why you have TextReader and TextWriter on top of streams, etc.. However, sometimes it's useful to have polymorphism for accessing streams, especially when porting C#/java code to D. In that case it would be pretty trivial to port the base classes to D and implement them using the D ranges. L. |
November 08, 2013 Re: File IO: C# streams VS iterators? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lionello Lunesu | On 2013-11-08 04:22, Lionello Lunesu wrote: > However, sometimes it's useful to have polymorphism for accessing > streams, especially when porting C#/java code to D. In that case it > would be pretty trivial to port the base classes to D and implement them > using the D ranges. For that, there's Tango: https://github.com/SiegeLord/Tango-D2 http://www.dsource.org/projects/tango/docs/current/ -- /Jacob Carlborg |
November 08, 2013 Re: File IO: C# streams VS iterators? | ||||
---|---|---|---|---|
| ||||
Posted in reply to DDD | On 2013-11-08 01:57, DDD wrote: > I was watching a dconf talk about porting C# code to D. One thing that > came up was there isn't anything like C# streams for D. Walter said he > thinks iterators (unless I remember wrong) is superior. The speaker > agreed but said it isn't a drop in replacement so that is an issue if > you want to port. > > I haven't access file in D and i'm completely confused. What are > iterators in regards to file IO? he must have said ranges. A range is like a pair of iterators. It's heavily used in D. -- /Jacob Carlborg |
Copyright © 1999-2021 by the D Language Foundation