for() with 4 arguments to allow postcondition
Jacob Carlborg
doob at me.com
Tue Jun 19 04:22:02 PDT 2012
On 2012-06-19 12:51, Michel Colman wrote:
> I have a suggestion for D (which might make it into C/C++ as
> well, but I thought D would be a more accessible place to suggest
> it):
>
> for(initializer; precondition; postcondition; increment)
>
> would allow avoiding a useless comparison before the start of the
> first iteration of a "for" loop in those cases where the
> programmer knows the loop will always iterate at least once. This
> new 4-argument version could exist alongside the old 3-argument
> version. An extra semicolon is all it would take to turn a
> precondition into a postcondition.
Isn't this what a do-while loop is for, or am I missing something?
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list