Bug 20304 – Implement variadic parameters for lambdas

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-10-16T09:25:36Z
Last change time
2024-12-13T19:05:53Z
Keywords
betterC
Assigned to
No Owner
Creator
Max Samukha
Moved to GitHub: dmd#17925 →

Comments

Comment #0 by maxsamukha — 2019-10-16T09:25:36Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:05:53Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17925 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB