Proposal: takeFront and takeBack

Mehrdad wfunction at hotmail.com
Wed Jul 4 01:20:58 PDT 2012


On Wednesday, 4 July 2012 at 08:18:35 UTC, Mehrdad wrote:
> On Wednesday, 4 July 2012 at 08:16:32 UTC, Roman D. Boiko wrote:
>> On Wednesday, 4 July 2012 at 08:13:10 UTC, Mehrdad wrote:
>>> What's wrong with moveFront()?
>>
>> It has different semantics. For example, it is only supported 
>> for ranges which have movable elements. After moveFront, the 
>> element which was placed in the front position is replaced by 
>> E.init (E is element type).
>
> WHOA I did not know that.
>
> I just thought it was front() + popFront()...
>
> In that case I think we _really_ need to get the naming right 
> (consume is horrible, IMO -- very unintuitive) to avoid 
> confusion....

I propose we just allow (but not require) popFront() to return 
ElementType!(R) instead of void?

That way, people who need the performance can check to see the 
return type, and use it without front() if needed.


More information about the Digitalmars-d mailing list