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"))