On Sunday, 31 July 2016 at 04:55:31 UTC, deadalnix wrote:
On Saturday, 30 July 2016 at 21:42:42 UTC, cym13 wrote:
The most interesting is to use structs to mimic keyword
arguments for
functions. By encapsulating possible arguments in a struct it
is possible to
use in-place initialization to provide a clean interface very
similar to
keyword arguments such as seen in python or ruby.
That doesn't help. In fact, it makes things worse as now
constructor calls and function call do not have the same
syntax. You've just created an holly mess in the parser.
If something we should strive to get constructor call more like
regular function call rather than less (for instance by
behaving the same way when it comes to IFTI).
It is also unclear how overload resolution is supposed to work.
If I may suggest one thing it is to not start with the intended
result for the DIP, but start from the intended change int he
language, then, and only then, examine what comes out of it.
I don't understand this comment. This isn't about construction,
it's about initialization, the call can occur only at one precise
time and no there is no overload concern as there is no function
call. The proposed change is litteraly just equivalent to the
already existing struct initialization, just made usable:
struct S {
int a;
int b;
}
auto s = S(b:42);
// equivalent to
S s = { b:42 };
Having the possibility to initialize structs without tying them
to a variable
proves useful when combined with functions that take this struct
but those
functions aren't directly impacted by the change.