On 2012-04-06 14:55, Manu wrote:
On 6 April 2012 15:38, Piotr Szturmaj <bncr...@jadamspam.pl
<mailto:bncr...@jadamspam.pl>> wrote:
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"))
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.
It depends on what we want out of attributes.
--
/Jacob Carlborg