Custom attributes (again)

deadalnix deadalnix at gmail.com
Fri Apr 6 07:25:33 PDT 2012


Le 06/04/2012 14:23, Jacob Carlborg a écrit :
> On 2012-04-06 05:30, Ary Manzana wrote:
>
>> I don't understand the difference between "storage class" and "type
>> constructor". I guess I do. But my answer is the same as deadalnix: they
>> are attached to declarations (at compile time).
>>
>> Can you give us an example of the confusion that arose? I can't
>> understand it without examples.
>>
>> I think it should work like this:
>>
>> @custom
>> class Foo {
>>
>> @ custom
>> void bar() { }
>>
>> void baz() { }
>> }
>>
>> class Other {}
>>
>> __traits(hasAttribute, Foo, 'custom') --> true
>> __traits(hasAttribute, Other, 'custom') --> false
>>
>> // I have no idea how to iterate the members of Foo, or get a reference
>> to the "bar" method... I can't understand what __traits(getMember)
>> returns from the docs...
>
> 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".
>

As foo isn't a declaration, I don't think it is attribute we want here. 
Or an extension, because it have a lot of consequences.


More information about the Digitalmars-d mailing list