On Friday, 21 October 2016 at 19:20:25 UTC, Daniel Kozak wrote:
Dne 21.10.2016 v 20:49 Patric Dexheimer via Digitalmars-d
napsal(a):
Quite sure that this was already discussed, but.. any chance
of this on D?
No (I hope so)
There are a lot of places where it should make the code clear.
Can you elaborate on this?
I always have to create shorter aliases for the most used
structs. (which i think is awkward sometimes)
Why? (I do not see any relation to Uniform initialization)
egs:
//D
alias vec3 = Tuple!(float, "x", float, "y", float, "z");
vec3[] vectors = [
vec3(1.0,0.0,1.0),
vec3(2.0,1.0,1.0),
vec3(3.0,2.0,1.0)
];
//C++ equivalent
vec3 vectors[] = {
{1.0,0.0,1.0},
{2.0,1.0,1.0},
{3.0,2.0,1.0}
};
//D
auto return_value = get_struct(); //don´t need to write the
return type
set_struct( StructName(value1, value2) );
//C++
set_struct( {value1, value2} ); //don´t need to write the
argument type
//D in case of large struct names
alias v = VeryLargeStructName; //not cool
v[] vectors = [
v(1.0,0.0,1.0),
v(2.0,1.0,1.0),
v(3.0,2.0,1.0)
];
I find myself falling with frequency on examples that will
benefit from the c++ uniform initialization.
"No (I hope so)"
Can you explain why you think is a bad idea?