popFrontExactly?

2012-11-18 Thread monarch_dodra
How does the community feel about having a "popFrontExactly" in phobos? "popFrontN" is like "take": Safe, but more costly: It double checks there actually *are* "n" elements in the range, and if not, stops pop-ing. When using popFrontN, more often th

Re: popFrontExactly?

2012-11-22 Thread Jonathan M Davis
rsonally, I think that I would have argued for popFrontN being popFrontExactly in the first place, but it's obviously too late for that. In probably all cases that I use popFrontN, what I'd want would be popFrontExactly (though popFrontNExactly would probably be a better name given its co

Re: popFrontExactly?

2012-11-22 Thread Kapps
, but I also worry about a proliferation of such functions. Personally, I think that I would have argued for popFrontN being popFrontExactly in the first place, but it's obviously too late for that. In probably all cases that I use popFrontN, what I'd want would be popFront

Re: popFrontExactly?

2012-11-23 Thread Jonathan M Davis
It would be simple to have a basic > fallback implementation of methods such as popFrontExactly, then > simply use range.popFrontExactly to get the more performant one > if the range supports it, and if not get the fallback. > > It would have to be clear in the documentation that t

Re: popFrontExactly?

2012-11-23 Thread Tobias Pankrath
helper library. And I would call in popFrontExactly, not popFrontNExactly. The latter is just hard to read and unnecessarily so.

Re: popFrontExactly?

2012-11-23 Thread monarch_dodra
On Friday, 23 November 2012 at 08:42:18 UTC, Jonathan M Davis wrote: I think that we'll probably need to add them in this case due to efficiency concerns, but it's not without cost. We don't want too many stray functions doing almost the same thing in Phobos. - Jonathan M Davis I'd say it's

Re: popFrontExactly?

2012-11-23 Thread Dmitry Olshansky
it, but now we have UFCS. It would be simple to have a basic fallback implementation of methods such as popFrontExactly, then simply use range.popFrontExactly to get the more performant one if the range supports it, and if not get the fallback. It would have to be clear in the documentation that

Re: popFrontExactly?

2012-11-23 Thread monarch_dodra
to have to check if the range supported it, use that, and if not fake it, but now we have UFCS. It would be simple to have a basic fallback implementation of methods such as popFrontExactly, then simply use range.popFrontExactly to get the more performant one if the range supports it, and if

Re: popFrontExactly?

2012-11-23 Thread Jonathan M Davis
n the long run, > this makes "drop" *un*-safe... I don't know if we can get away with it or not (given the possibility of breaking code), but given that drop doesn't return how many elements were popped (unlike popFrontN), I'd favor simply making it drop the exact numbe

Re: popFrontExactly?

2012-11-23 Thread Mehrdad
I wouldn't mind also adding a popFrontApproximately() =P

Re: popFrontExactly?

2012-11-23 Thread Jonathan M Davis
On Saturday, November 24, 2012 07:43:26 Mehrdad wrote: > I wouldn't mind also adding a popFrontApproximately() > > =P So, what's it do? Randomly pick a number close to the number that you give it and try to pop that many? :) - Jonathan M Davis

Re: popFrontExactly?

2012-11-23 Thread Mehrdad
On Saturday, 24 November 2012 at 06:50:43 UTC, Jonathan M Davis wrote: On Saturday, November 24, 2012 07:43:26 Mehrdad wrote: I wouldn't mind also adding a popFrontApproximately() =P So, what's it do? Randomly pick a number close to the number that you give it and try to pop that many? :)

Re: popFrontExactly?

2012-11-26 Thread monarch_dodra
; if they want popFrontExactly. - Jonathan M Davis Well, if the goal was reducing the amount of functions, or avoiding hard to grasp variants, then I'd agree. But in this case, the goal (IMO) is to provide convenient and intuitive tools for coding. I think (but this is my point of vi