Discussion Thread: DIP 1033--Implicit Conversion of Expressions to Delegates--Final Review
Q. Schroll
qs.il.paperinik at gmail.com
Sun Nov 22 20:49:27 UTC 2020
In the Feedback thread, Walter wrote:
> All this [the proposed changes] does is replace the 'lazy' with
> the delegate syntax. D already uses this for variadic lazy
> arguments, and nothing has come up bad about it.
Have you ever tried to use attributes on them? It's a mess. The
expressions converted to delegates are not at all equivalent to
literal delegates when attributes are at play.
int fun(int delegate() pure [] xs...) pure
{
foreach (x; xs)
if (auto value = x())
return value;
return 0;
}
void impureContext()
{
import std.stdio : write;
int impureFactory() { write(""); return 0; }
fun(impureFactory()); // passes, but why??
fun(&impureFactory); // fails, no surprise
fun(() => impureFactory()); // fails, no surprise
}
void pureContext() pure
{
int pureFactory() pure { return 0; }
fun(pureFactory()); // passes, no surprise
fun(&pureFactory); // passes, no surprise
fun(() => pureFactory()); // passes, no surprise
}
The DIP should make clear, that "simply" lowering expressions to
delegates isn't what's going on.
More information about the Digitalmars-d
mailing list