dennis luehring wrote:
i don't get the GC relation here?

all attribute values are static const - because they are type-related (static) and read-only, attributes are type orientated not instance orientated

C# doesn't support free-types (everything's wrapped up in classes) so the technique isn't going to be identical. In D, you'd need to be able to declare an attribute on virtually any entity declaration and have the compiler dish out the appropriate code.

Trove's suggesting that the compiler simply looks up user-defined functions associated with <AttributeX> and inject the code into the appropriate place, which I think is a good idea. The problem I see is how to do more advanced structural changes like C# does with [FieldOffset(0)]. Things like:

    @Int.Fast int index;
    assert(index.sizeof == int.sizeof) // always?

which might break the type system, so I'm not sure it's even possible. The compiler might have passed the point of no-return with such attributes.

Regardless, I think was Trove's suggesting would work well.

Reply via email to