User defined attributes use

matovitch camille.brugel at laposte.net
Mon Sep 16 03:47:51 PDT 2013


On Monday, 16 September 2013 at 10:36:16 UTC, Bienlein wrote:
> On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote:
>> All your examples are great, thank you ! Is there a way to 
>> omit validate such that the compiler would call it implicitly ?
>>
>> For example :
>>
>> class C {
>>  ...
>> }
>>
>> void fun(@nonNull C c) {
>>  ...
>> };
>>
>> C c;
>> fun(c);  //compilation error since C is null
>
> Very interesting. Does this go beyond annotations in Java? Just
> out of curiosity, no language war intended.
>
> -- Bienlein

And with template parameters.

fun(@Arithmetic T)(...) {...}

alias fun!string funstr; //compilation error since a string is 
not an arithmetic type


More information about the Digitalmars-d-learn mailing list