Default initialization of struct
Daniel Kozak
kozzi11 at gmail.com
Wed Feb 13 06:20:24 PST 2013
> entity4: You're talking about static opCall and named
> parameters. I'm pretty sure named parameters have been rejected
> as parameter names would be part of the public interface for
> functions.
No, I dont want named parameters, because I agree it is not good
idea to have parameter names part of public interface. I speak
about syntax sugar, how to do this:
module main;
import std.stdio;
struct Entity
{
string name;
}
static Entity entity = {name: "EntityName"};
@entity
class A {
}
void main(string[] args)
{
auto attributes = __traits(getAttributes, A);
writeln(attributes[0]);
}
by this code:
module main;
import std.stdio;
struct Entity
{
string name;
}
@Entity(name : "EntityName")
class A {
}
void main(string[] args)
{
auto attributes = __traits(getAttributes, A);
writeln(attributes[0]);
}
More information about the Digitalmars-d
mailing list