[Issue 21106] New: Add type inference for constructor calls
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 3 21:49:30 UTC 2020
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 at puremagic.com
Reporter: porton at 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.
--
More information about the Digitalmars-d-bugs
mailing list