On Tue, Jul 15, 2014 at 12:46:04PM -0700, H. S. Teoh via Digitalmars-d wrote: > On Tue, Jul 15, 2014 at 07:16:17PM +0000, Martin Krejcirik via Digitalmars-d > wrote: > > On Tuesday, 15 July 2014 at 18:50:08 UTC, John Colvin wrote: > > >and not just because I don't like the comma. I'd say it's generally > > >bad practice to hide that write to `flag` inside the > > > > You are right for the 'final' code, but the point of my example is, > > that I can move the flag to another if and don't have to change > > anything else. > > > > Also an assignment is not allowed in a condition and without the comma > > operator, it wouldn't be possible at all. That's way too restrictive. > > Not true: > > T* ptr; > if ((ptr = getPtr()) !is null) { > ... > } [...]
Better yet, this syntax is supported: if (auto ptr = getPtr()) { // ptr is not null here } T -- Real men don't take backups. They put their source on a public FTP-server and let the world mirror it. -- Linus Torvalds