[Issue 10491] Type inference for function arguments with default value
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jun 28 21:13:52 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10491
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2013-06-28 21:13:50 PDT ---
I don't like the enhancements of this kind. Because:
1. Default argument is not so often used. Then, reduction amount of the code is
very limited.
2. It breaks consistency of C-style languages that all of function parameters
in function signature have their own type explicitly.
3. It would introduce one more forward reference possibility.
void foo(auto a = bar()) {} // inference
auto bar()
{
alias T = ParameterTypeTuple!foo[0]; // requires foo's complete signature
return T.init;
}
void main()
{
auto x = bar();
}
Already, auto return, function attribute inference has same possibility. They
sometimes produces legitimate (but difficult to understand) forward reference
errors.
4. `auto ref` / `in ref` is still debatable. This enhancement might have
interference with it.
----
Side note: Today, issue 7152 is implemented. By that,
void foo(in VeryLongNamedStruct x = VeryLongNamedStruct(1)) {}
might be shorten to:
void foo(in VeryLongNamedStruct x = 1) {}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list