On 4/6/12 1:35 AM, Walter Bright wrote:
On 4/5/2012 5:00 AM, Manu wrote:
C# and Java both have attributes, following these established design
patterns, I
don't think there should be any mystery over how they should be
implemented.

At the Lang.NEXT conference over the last 3 days, I was able to talk to
many smart people about attributes. But I did find some confusion - are
they best attached to the variable/function (i.e. "storage class"), or
attached to the type ("type constructor")? I think the former. Attaching
it to the type leads to all sorts of semantic issues.

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...

Reply via email to