Custom attributes (again)

Manu turkeyman at gmail.com
Fri Apr 6 05:55:23 PDT 2012


On 6 April 2012 15:38, Piotr Szturmaj <bncrbme at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120406/ac7b83fd/attachment.html>


More information about the Digitalmars-d mailing list