Discussion Thread: DIP 1033--Implicit Conversion of Expressions to Delegates--Community Review Round 1
kinke
noone at nowhere.com
Wed Apr 22 11:56:44 UTC 2020
I don't think this is a good idea. One of the problems with
`lazy` IMO is that one needs good IDE support to somehow
highlight that the argument expression isn't evaluated before the
call, and might not be evaluated at all:
// in some other module:
void foo(lazy int i) {}
void main()
{
int i = 1;
foo(++i);
assert(i == 1); // what? not incremented above? ah yeah, lazy
and not evaluated at all by foo
}
The proposal would extend that problem to regular delegate params
too. So I find the explicit version (`() => ++i`) better to make
that clear. I don't think the 'overhead' of putting an additional
`() =>` in front of the expression justifies introducing the
proposed implicit convertibility.
More information about the Digitalmars-d
mailing list