Proposal: takeFront and takeBack

Roman D. Boiko rb at d-coding.com
Wed Jul 4 06:42:47 PDT 2012


On Wednesday, 4 July 2012 at 12:40:41 UTC, Tobias Pankrath wrote:
>> You have to maintain 2 version of you algorithm. This is more 
>> work to test, to maintain, and it is likely to introduce more 
>> bugs.
>>
>> More code == more bugs. More NPATH = more bugs and harder to 
>> test and to maintain.
>>
>> In addition, this will result in practice in less generic 
>> code, because one may not need the version of the algorithm 
>> without consume primitives in his/her own code and not code it 
>> at all.
>
> Since the performance problem seems mainly to materialize for 
> string processing code an alternative to this proposal would be 
> to add those functions only for strings. As far as I heared, 
> most of phobos is already special cased for string so the 
> maintenance overhead wouldn't be too big.

That seems to be reasonable.

Drawback is that Phobos algorithms would not ever take advantage 
of consumeFront for anything else (even if that was defined).


More information about the Digitalmars-d mailing list