digitalmars.D.bugs - [Issue 21106] New: Add type inference for constructor calls
- d-bugmail puremagic.com (28/28) Aug 03 2020 https://issues.dlang.org/show_bug.cgi?id=21106
https://issues.dlang.org/show_bug.cgi?id=21106 Issue ID: 21106 Summary: Add type inference for constructor calls Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dlang.org Assignee: nobody puremagic.com Reporter: porton narod.ru I propose to add type inference (similar to one for functions) for constructor calls, that is to make the following program legal: class C(T) { this(T) { } } void main() { immutable x = new C(0); } This would simplify programming eliminating the need to create a factory function or factory functions for each template class. Pro: shorter programs. Con: some consider it a good practice to make a factory function ALWAYS. Pro: even if you create a factory function, the body of this function itself would be shortened. --
Aug 03 2020