<div class="gmail_quote">On 6 April 2012 15:38, Piotr Szturmaj <span dir="ltr"><<a href="mailto:bncrbme@jadamspam.pl">bncrbme@jadamspam.pl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">Jacob Carlborg wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I would like to have the possibility to attach attributes to types and<br>
parameters as well. Some think like this:<br>
<br>
class Bar<br>
{<br>
@not_null(Foo) bar (@custom int a) {}<br>
}<br>
<br>
Where @not_null is attached to "Foo" and @custom is attached to "a".<br>
</blockquote>
<br></div>
Do you mean return type? I think your syntax has some serious disadvantages. Consider parameters and multiple attributes.<br>
<br>
For return types I'd like to see something like this:<br>
<br>
@return: not_null<br>
@return: MyAttr("foo")<br>
Foo bar(@custom int a) {}<br>
<br>
This is similar to C#'s [return: MyAttr]. Alternatively it might be:<br>
<br>
@return(not_null)<br>
@return(MyAttr("foo"))<br>
</blockquote></div><br><div>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.</div>
<div>You can't attribute a return value, since attributes aren't transferred along with assignments, they are bound to their respective declaration.</div>