Proposal: user defined attributes

Alvaro alvaroDotSegura at gmail.com
Fri Mar 16 18:24:17 PDT 2012


El 16/03/2012 14:35, Adam D. Ruppe escribió:

>
> We introduce two new things to the language:
>
> 1) the @note(expression) attribute. You can put
> as many "notes" on a declaration as you want by
> simply listing them.
>


I like that.

I learned about annotations a couple years ago in two contexts:

- Web Services in Java and C#
- Hibernate in Java

They come very handy and are hard to beat with current language features.

[WebService]
public class Service : WebService
{
     [WebMethod]
     public string helloWorld() {
         return "Hello World";
     }
}

What coult be a similar D with annotations?:

@note(WebService)
class Service : WebService
{
     @note(WebMethod)
     string helloWorld() {
         return "Hello World";
     }
}

and have some CTFE stuff generate the magic?


More information about the Digitalmars-d mailing list