"for" statement issue

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 23 04:08:58 PDT 2016


On Saturday, 22 October 2016 at 17:11:26 UTC, ag0aep6g wrote:
> How is it guaranteed that `a` doesn't have side effects? May be 
> a function call, since empty parentheses can be omitted in 
> calls.

I missed that case. (Insert grumble about non-UFCS parenthesis 
omission being allowed).

> The lambda itself is a value, no?
>
> ----
> int a() { import std.stdio; writeln("a"); return 1; }
>
> void main()
> {
>     int delegate(int) dg = (a, b => a + b);
> }

OK. Though AIUI from 2.072 a() must return void for the comma 
expression to compile (then a+b wouldn't compile either).


More information about the Digitalmars-d mailing list