Joseph Rushton Wakeling:

It wasn't clear to me what the benefits were, though,

For this function not a lot, but it's a good habit to have.


especially as I did consider making this an enforce() rather than an assert().

If you want to use enforce then don't put them in pre-conditions.
But usually asserts should suffice.


And "in size_t v" is enough compared to "immutable size_t v".

Does "in" allow for subsequent mutation _within_ the function?

"in" implies scoped const. So you can't mutate the argument inside the function/method. For reference types "immutable" is even stronger.


For such kind of code I suggest to use UFCS chains.

Can you explain in a little more detail? It's not an aspect of programming I'm familiar with.

auto r1 = iota(_sumHead[v], _sumHead[v + 1]).map!(a => _tail[_indexHead[a]]); auto r2 = iota(_sumTail[v], _sumTail[v + 1]).map!(a => _head[_indexTail[a]]);
return chain(r1, r2);


Anyway, thanks very much for the useful feedback :-)

You are welcome,
bye,
bearophile

Reply via email to