Custom attributes (again)
    Piotr Szturmaj 
    bncrbme at jadamspam.pl
       
    Fri Apr  6 06:57:11 PDT 2012
    
    
  
Manu wrote:
> On 6 April 2012 15:38, Piotr Szturmaj <bncrbme at jadamspam.pl
>     For return types I'd like to see something like this:
>
>     @return: not_null
>     @return: MyAttr("foo")
>     Foo bar(@custom int a) {}
>
>     This is similar to C#'s [return: MyAttr]. Alternatively it might be:
>
>     @return(not_null)
>     @return(MyAttr("foo"))
>
>
> There's no need to attribute a return value. A) I think you're confusing
> it with attributing *types* again, and B) you can just attribute the
> function its self, and have access to precisely the same information.
> You can't attribute a return value, since attributes aren't transferred
> along with assignments, they are bound to their respective declaration.
See http://msdn.microsoft.com/en-us/library/b3787ac0%28v=vs.80%29.aspx
Attributes on return values are useful for RPC methods. For example: 
with attribute, one can specify how return value is serialized/marshalled.
In C#, attributes can be specified on function, parameters and return 
type _simultaneously_. I don't think we should limit D ones to functions 
and parameters.
    
    
More information about the Digitalmars-d
mailing list