Dne 21.10.2016 v 23:21 Patric Dexheimer via Digitalmars-d napsal(a):

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}
};

this works for D too:

import std.stdio;

struct S
{
    int a;
    int b;
}
void main()
{
    S[] s = [{ 1, 2 }];
    writeln(s[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
OK this does not work but I do not think it is releated to Uniform initialization, but it is more something like cast to parametr type or something like that

Can you explain why you think is a bad idea?
Because there is no need. In c++ it is disaster because there is milion way how to initialize something, it is really hard to understand and inconsistent

Reply via email to