[Issue 12945] New: Deprecation for legacy static opCall feature in initializing
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jun 18 22:40:21 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12945
Issue ID: 12945
Summary: Deprecation for legacy static opCall feature in
initializing
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
It is an old feature to emulate constructor call from D1 age.
struct S {
int num;
static S opCall(int n) {
S s;
s.num = n;
return s;
}
}
void main() {
S s = 1;
// This line is translated to:
// S s = S.opCall(1);
}
But in D2, "implicit constructor call" feature properly supports such the
initializing syntax.
struct S {
int num;
this(int n) {
this.num = n;
}
}
void main() {
S s = 1;
// This line is translated to:
// S s = S(1);
}
Therefore, we can deprecate/remove the problematic opCall feature in
initializing.
--
More information about the Digitalmars-d-bugs
mailing list