Suggestion: allow implicit default-initialization using type x = auto syntax. This is the same as type x = type.init and type x = type().
This will be especially handy for functions with optional parameters.
Before:
void fun(
int x = 0,
double x = double.nan,
bool flag = false,
string str = "",
void* ptr = null,
SomeStruct = SomeStruct(),
int[4] arr = [0, 0, 0, 0])
After:
void fun(
int x = auto,
double f = auto,
bool flag = auto,
string str = auto,
void* ptr = auto,
SomeStruct = auto,
int[4] arr = auto)
Possible alternatives:
int x = init: most obvious, but this would require makinginita reserved keyword.int x = default: more clear thanautobut also quite longer.int x = {}: incompatible with D syntax.
Permalink
Reply