[Issue 20304] New: Implement variadic parameters for lambdas
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 16 09:25:36 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20304
Issue ID: 20304
Summary: Implement variadic parameters for lambdas
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: maxsamukha at gmail.com
I do not know whether this should be an enhancement or bug. Variadic parameters
for lambdas are unspecified. The syntax is accepted, but any attempt to
instantiate such a lambda with multiple arguments results in a semantic error.
alias foo = (a...) {
};
void main() {
foo(1, 2);
}
onlineapp.d(5): Error: template onlineapp.__lambda4 cannot deduce function from
argument types !()(int, int), candidates are:
onlineapp.d(1): onlineapp.__lambda4
https://run.dlang.io/is/lByBjC
Why are variadic lambdas needed (apart from they should just work)? At present,
-betterC tries to do codegen for functions that are only intended for CTFE,
unjustifiably precluding CTFE for anything that requires GC, typeinfo etc. The
only existing workaround is to transform the functions into lamdas. However,
writing functions such as string formatters is painful without variadic
parameters. It would become bearable, if this bug is fixed, until a proper way
of marking CTFE-only functions is implemented.
--
More information about the Digitalmars-d-bugs
mailing list