DIP 1002 (TryElseExpression) added to the queue
pineapple via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 28 03:55:49 PDT 2016
On Wednesday, 28 September 2016 at 07:33:48 UTC, ikod wrote:
> Thanks!
>
> There is also useful for/else construct in Python
>
> https://docs.python.org/2/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops
>
> I'd like to see it in D.
While I appreciate being able to use for/else and while/else in
Python, in D using gotos provides a more flexible (if more
archaic) solution.
But if we were to borrow else from Python for loops - which isn't
a terrible idea since gotos are messy and make code harder to
read - I'd suggest augmenting the construct with another block
that evaluates only when the loop _wasn't_ broken.
Make a DIP!
More information about the Digitalmars-d
mailing list