<div>I just want to add more real-world experience to the controversy.</div>I'm finding myself needing to use custom attributes almost every day.<div><br></div><div><div>I have numerous systems that need to scan the module for things marked accordingly to automate bindings to their respective systems.</div>
<br class="Apple-interchange-newline"></div><div>This is my current list of attributes I want to mark things with:</div><div> Export to game engine</div><div> Export to script language</div><div> Import from game engine</div>
<div> ** Import from script language (tentative, I'm sure I'll need it in a few more days)</div><div> Expose to editor (with additional properties; description, edit type, etc)</div><div> Serialise (load/save game)</div>
<div> Replay serialisation (a different kind of serialisation that works with different data sets)</div><div><br></div><div>And others I've encountered in passing that I can't recall right now.</div><div><br></div>
<div>As you can imagine, any attempt to 'work around' the lack of an attribute system, ie, (ab)using enums, etc as have been suggested, leads to a big mess in the context of all these requirements.</div><div>Management of such lists of stuff in disconnected places in code is time consuming, thoroughly annoying, error-prone, difficult to maintain, and leaves programmers with the bitter taste of C++.</div>
<div>Alternatively, wrapping virtually every single declaration made in mixin() and declaring everything as strings is even more nasty, and the contrast between mixin() declarations and 'normal' declarations looks completely stupid. (Totally unreadable + difficult to understand, breaks intellisense, code completion, syntax hilighting, etc... ie, unusable)</div>
<div><br></div><div>Does anyone have a *realistic* suggestion for emulating custom attributes? Something that doesn't have any(/many) of the side effects I mention?</div><div>I haven't come up with anything that's acceptable yet.</div>
<div><br></div><div>If not, I assert that D absolutely needs a custom attribute system. For us here, this will enable D the single biggest advantage over using C++ in the same context that I've identified so far.</div>
<div>D's meta-programming is amazing, but sadly, proving pointless to me right now without being able to mark stuff appropriately. All the meta magic is hovering just out of my grasp, due to the fact I have no way to indicate what items should involve with what systems.</div>
<div>Currently, I have to maintain big registry tables of junk that must be amended/updated any time anyone adds/changes anything... and I'm feeling rather embarrassed when I tell the other non-D programmers that they just need to update this table here... and here... and make sure that's in sync too before their stuff will just 'magically' work ;)</div>
<div><br></div><div>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.</div>