Custom attributes (again)
Piotr Szturmaj
bncrbme at jadamspam.pl
Fri Apr 6 05:38:32 PDT 2012
Jacob Carlborg wrote:
> I would like to have the possibility to attach attributes to types and
> parameters as well. Some think like this:
>
> class Bar
> {
> @not_null(Foo) bar (@custom int a) {}
> }
>
> Where @not_null is attached to "Foo" and @custom is attached to "a".
Do you mean return type? I think your syntax has some serious
disadvantages. Consider parameters and multiple attributes.
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"))
More information about the Digitalmars-d
mailing list