Annotations, was Re: Custom attributes C#
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Thu Sep 27 14:02:15 PDT 2007
Jari-Matti Mäkelä wrote:
> Daniel Keep wrote:
>
>> The point is to give programmers a way of adding extra information about
>> a declaration that you wouldn't normally be able to convey.
>>
>> Granted, you *could* do this in D right now; in much the same way you
>> can do OO programming in assembler. You could probably fake it with
>> variadic templates and structs, etc., but it'd be ugly as heck.
>
> Makes me think that maybe e.g. 'unittest', 'deprecated' and pragma should
> have been annotations instead of keywords. Annotations feel a much more
> extensible facility than a fixed set of keywords. I'm not really sure what
> benefits the C# syntax has over @java @annotations, but D (or at least
> tools) could really have a use for annotations in general. The language
> should not dictate what 3rd party tools can and cannot do.
Indeed. It seems to follow a general pattern that software meant to be
used by a large population may benefit a lot from extensibility (even if
the core purpose of the program does not require extensibility). We have
examples in desktop applications such as Mozilla, Firefox, Winamp; in
development tools such as Eclipse; and in games this principle also
seems to apply (the ability to mod a game greatly increases its value,
there are even games born out of mods, such as Counter-Strike)
After Java annotations came out, third party tools quickly adopted it to
various uses, one of them being to define Object-Relational DB mappings,
like the example Ary posted (for C#). To anyone who has used XML-based
OR mapping (like I have in the past, with Apache OJB), you know how
inane and annoying that is. I've recently taken a look at OR mapping
using Java annotations and it's way, *way* better. Safer, less brittle,
less verbose and more readable. This kinda of stuff can open whole new
segments in the target population of a language.
But in any case, we'd need runtime reflection first, to have something
like this. Compile-time annotations only would be of limited use (I think).
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list