Eigenpoll : D wish list : Custom Attributes 

Custom attributes similar like in C# and Java. But since D is only going to have compile time reflection, this can be simply tagging the method in some way. And retrieving the information at compile time.

Could D have custom attributes like in C# ?

public class MyCustomAttribute:Attribute
{
public MyCustomAttribute( string text)
{
}
...
}


class MyClass
{
[MyCustom("my text")]
void DoStuff()
{
}
}

The attributes can then be retrieved by system reflection. An attribute is
a class thus can contain code.


I was thinking of something similar in D, but simpler

attribute published; // published would then be an attribute.

class Window
{
attr(published) void caption(char [] text)
{
}
}

__traits( allAttributes, win.caption)

But of course it could be something better than this.



Report this item for cleanup