Should we have an Unimplemented Attribute?

Piotr Szturmaj bncrbme at jadamspam.pl
Wed Feb 2 15:38:02 PST 2011


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.


More information about the Digitalmars-d mailing list