Tricky semantics of ranges & potentially numerous Phobos bugs

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Oct 17 09:22:55 PDT 2012


On 10/16/12 11:17 AM, H. S. Teoh wrote:
> OTOH, if we clearly state that .front may not persist past the next
> popFront(), then it would be up to the caller to .dup the return value,
> or otherwise make a safe copy of it (or use the value before calling
> popFront()).
>
> The current ambiguous situation leads to one range doing one thing, and
> another range doing something else, and either way, either this code
> will break or that code will break.

Input ranges don't guarantee preservation of .front upon calling 
.popFront. They do allow several to .front (without an intervening call 
to .popFront) that should return the same result (i.e. a one-element 
buffer).

Andrei


More information about the Digitalmars-d mailing list