On Thursday 03 February 2011 03:02:04 Jacob Carlborg wrote: > On 2011-02-03 00:38, Piotr Szturmaj wrote: > > Andrej Mitrovic wrote: > >> We know what a Deprecated Attribute is for: > >> http://www.digitalmars.com/d/2.0/attribute.html#deprecated. > >> > >> You can use a compiler switch to enable using these: > >> -d > >> allow deprecated features > >> > >> But what about structs/classes/functions/etc which are partially > >> implemented, but still unusable? Marking them with deprecated doesn't > >> make sense, as this will likely confuse both the user and the library > >> writers. Would it be overkill to introduce a new attribute? > >> > >> The idea came after I've spent some good time trying to get druntime's > >> getMembers function to work in my code, only to find out from this NG > >> that it's not properly implemented. > >> > >> Discuss? > > > > In C# there is NotImplementedException for that. > > > > public class A > > { > > public int foo() > > { > > throw new NotImplementedException(); > > } > > } > > > > I see people ask for new attributes. Why not add user defined attributes > > into language? C# has custom attributes and Java has custom annotations. > > > > Custom attributes could be just classes (as in C#): > > > > class GuidAttribute : Attribute > > { > > string guid; > > > > this(string guid) > > { > > this.guid = guid; > > } > > } > > > > used like this (COM interfaces): > > > > @Guid("48eecd81-35d7-4d4e-9ab8-479a38713053") > > interface MyInterface > > { > > byte foo(); > > ulong bar(); > > } > > > > or used for ORM: > > > > @DBTable("users") > > struct UserRow > > { > > @NotNull string username; > > @NotNull string password > > ubyte age; > > } > > > > There would be also need for some method to enumerate those attributes > > at compile time/run time. We already have that possibility for > > predefined attributes. > > I would love to have user defined attributes/annotations.
I agree with that whole-heartedly. They really should be added at some point, though since they should be backwards compatible, there's not necessarily any rush given everything else that needs to be done. Still, I don't think that we need an attribute for this particular case. - Jonathan M Davis