If Statement with Declaration

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 21 15:14:56 PDT 2017


On Friday, July 21, 2017 17:32:48 Andrei Alexandrescu via Digitalmars-d 
wrote:
> On 07/19/2017 09:30 AM, sontung wrote:
> [snip]
>
> This post:
> http://forum.dlang.org/post/vfjlpvpwuyfqoljvpkkw@forum.dlang.org seems
> to be identical to one on November 3, 2016:
> http://forum.dlang.org/post/dejodpslmjdovstdiwfz@forum.dlang.org.
>
> Hat tip for persistence!
>
> Regarding the feature itself: it seems to be fancied by the new
> languages, and C++ added it, too. I must be old school because I don't
> see much benefit in it, and don't quite find it natural. It's bizarre
> even lexically: "If the following ... oh wait let me insert some stuff
> ... as I was saying, if the following condition happens..." Conversely,
> I find the let/letrec syntax in functional languages a bit more convivial.

I would have thought that it was a fairly obvious extension given how for
loops work (especially since you can already declare variables in if
statements; you just can't do it and then use something else for the
condition), and it's less verbose than doing something with with, though I
suppose that getting with to work like this would be better than nothing. It
does seem unnecessarily verbose in comparison though.

- Jonathan M Davis



More information about the Digitalmars-d mailing list