On 04/14/2011 01:00 AM, Andrej Mitrovic wrote:
I'm trying to understand the design of ranges. Why does popFront only set the 
front() property to return the next element in the range? Why not return the 
element in the call to popFront right away?

For example code like this (which doesn't work since popFront doesn't return):
void main()
{
     int[] a = [1, 2];
     auto b = a.popFront;
     assert(a == [2]);
     assert(b == 1);
}

Isn't it wasteful to have to call both popFront() and front() to simultaneously 
remove an element from a range and return it? I mean it's an extra function 
call, right?

I like to have three members (even if not quite necessary, this cleanly separates notions). Why I don't understand is why empty and front are methods, not simple data members.

Denis
--
_________________
vita es estrany
spir.wikidot.com

Reply via email to