On 11 January 2014 00:26, monarch_dodra <monarchdo...@gmail.com> wrote:
> On Friday, 10 January 2014 at 14:13:37 UTC, marcpmichel wrote: > >> On Friday, 10 January 2014 at 14:02:21 UTC, Manu wrote: >> >> I won't start another annoying thread. >>> >>> What's the go with popFront()... it returns nothing? >>> I almost always want to pop and return the front element. I can't find a >>> function to do that... have I missed something again? >>> >> > There isn't (at least, not that I know of). I would be trivial to > implement, but because it would be implemented in terms of front/popFront, > it would not be any faster. > > *However*, depending on the range type (non-transitive), popping might > instantaneously invalidate the element you are operating on (think > "byLine", that returns a "char[]", not a "string"). > Since you mentioned it here yesterday, I thought 'byLine' would be useful this morning... but I can't find it! This is an embarrassing theme. Does it actually exist, and I am even further retarded... or did you just make that up? File seems to have one, but that's no good for general text processing. I can see std.string.splitLines, but that's not the same thing; it allocates in a case where I don't need to. It seems you have to use both the .front property to access the element, >> and popFront() to advance to the next element. >> I can't understand why you need two methods; maybe there's a very good >> reason for that. >> > > You *need* two methods for the very simple use case of reading without > popping. > > As for returning the popped element when calling pop: It's an extra cost. > C++ introduced back and pop_back (as well as pop/top) with those exact > semantics for this reason. D also adds an issue of data integrity. >