The new, new phobos sneak preview

Michel Fortin michel.fortin at michelf.com
Mon Apr 6 19:22:43 PDT 2009


On 2009-04-06 18:29:50 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> for (auto copy = range[]; !copy.empty; copy.popFront)
> {
>      auto e = copy.front;
>      body
> }

Perhaps it's a little off topic, but...

Wouldn't it be better if the language was made so that evaluating an 
array as a bool would yeild false when empty and true when not? This 
would avoid forcing the !empty double negation at many places like this 
one.

	while (range) range.popFront;

instead of

	while (!range.empty) range.popFront;

and

	for (auto copy = range[]; copy; copy.popFront)

instead of

	for (auto copy = range[]; !copy.empty; copy.popFront)

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list