Why D Needs Attributes (Was: Command-line arguments)

Lutger lutger.blijdestijn at gmail.com
Mon Jul 7 03:49:38 PDT 2008


Nick Sabalausky wrote:
 
> Clearly, you can implement any command-line you want using either method.
> But if you're going to disallow the latter method just because you can get
> the same effect with the former method, then not only does that break an
> important part of D's design philosophy, but you may as well start
> throwing away things like "while", "for" and "foreach" as well. After all,
> any loop you can implement with those constructs can already be
> implemented with conditionals and gotos. So why do we include them?
> Because the programmer may decide they're a better fit for what they're
> trying to do.

I'm not sure attributes alone are generic and generally useful enough to
support the argument that they enable a specific programming style. But
perhaps reflection / introspection is, and attributes as far as I
understand them are part of C#'s reflective capabilities, which are way
more powerful than what D has.

However, the limited reflective power of D is at least partly intentional
though it seems to be growing. I recall these motivations:
- Lots of reflection bloats object code
- D has and will have some more compile time reflection (templates,
__traits, is-expressions, etc.)
- In many cases, compile time reflection is a sufficient replacement for
runtime reflection
- In other cases reflective capabilities that are lacking can be built 
using compile time reflection 










More information about the Digitalmars-d mailing list