If Statement with Declaration

Moritz Maxeiner via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 20 07:30:05 PDT 2017


On Thursday, 20 July 2017 at 14:18:48 UTC, Jack Stouffer wrote:
> On Thursday, 20 July 2017 at 14:05:36 UTC, Iakh wrote:
>> It is not about reduce number of lines. It is about binding
>> related things in one statement.
>
> Even so, it's already been shown in this thread that the same 
> effect can be achieved via a block statement (doing exactly 
> what it was designed for)

This decreases readability by splitting up parts that (the 
programmer wants to) semantically belong together.

> or with a for loop.

Which is a hack decreasing readability, because it works opposite 
to what one generally expects when reading a looping control 
structure.

>
> It's an small increase in terseness for a decrease in 
> readability and an increase in complexity.

W.r.t to the `with` solution only: It's a noticeable increase in 
readability for a minor increase in complexity.


More information about the Digitalmars-d mailing list