std.c.stdio, std.stream std.c.file, ranges
Jonathan M Davis
jmdavisProg at gmx.com
Sun Sep 26 01:09:41 PDT 2010
On Sunday 26 September 2010 00:23:23 Joel Christensen wrote:
> Thanks for your reply Jonathan. Yes, I heard about stream being
> replaced, but since my code with binary files isn't very much, I can
> just redo it if I have to. I think I'll continue using std.c.file for
> the time being.
>
> I should learn about ranges.
You'll be able to do a lot more with stuff like std.algorithm if you have a good
understanding of ranges (I should also note that std.algorithm is a prime
example of why auto is such a good thing - you do _not_ want to have to use all
of the specific return types in std.algorithm directly).
This article by Andrei would be a good place to start:
http://www.informit.com/articles/article.aspx?p=1407357
There's also this presentation that he did on ranges at BoostCon 2009:
http://blip.tv/file/2432106
They require you to think differently about some things, but for a lot of stuff,
it can be very powerful and much simpler to do. One really cool thing is that
you can process a range pretty much like you'd process an slist in a functional
language like lisp or Haskell (you can use front and popFront() very similarly
to how head/car and tail/cdr are used in function languages).
I really love ranges, but they can take some getting used to. A lot of folks
seme to react fairly negatively to them intially, but once you've messed with
them a bit, you'll probably agree that in most cases, they're at least as good
if not superior to iterators.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list