Range to array
Namespace
rswhite4 at googlemail.com
Sat Jun 30 02:06:06 PDT 2012
> std.range already publicly import std.array.
Oh, good to known.
>
> Not to mention, if you're using ranges heavily, it's not all
> that uncommon to
> not actually need std.array.array very often. In general, if
> you're constantly
> converting ranges to arrays, then I'd argue that you're doing
> something wrong.
> There are definitely times when you need to convert a range to
> an array, but in
> general, you can just pass the result of one range-based
> function to another
> and operate on the data just fine without needing to convert to
> arrays at all.
> Worst case, you convert once you're done with all of various
> operations that
> you need to do on the data. But if you're passing arrays around
> rather than
> ranges, unless you actually need arrays for some reason, you
> should really
> consider passing ranges around like Phobos does. You're code's
> not going to be
> terribly efficient if you're constantly converting the results
> of range-based
> functions into arrays, since that means allocating more memory
> for the same
> data every time that you do that.
>
> - Jonathan M Davis
But a Range don't match any function that accept arrays. Or
should i prefer to use Ranges instead of arrays?
More information about the Digitalmars-d-learn
mailing list