|
|
|
|
|
by d110af5ccf
1778 days ago
|
|
> the language is fairly unusable until you write lots of macros This is not (typically) the case. It would be like saying that you need to write lots of templates to get things done in D. Metaprogramming is certainly very nice to have but it's not a requirement for the vast majority of tasks. It's important to note that Lisps are an entire family of languages; some implementations are batteries included while others are extremely minimal. Where things can get a bit confusing is that many macro implementations are so seamless that significant pieces of core language functionality are built in them. Schemes tend to take this to an extreme, with many constructs that I would consider essential to productive use of the language provided as SRFIs. > macros then become your personal undocumented wacky language That's Doing It Wrong™. You could as well argue to remove goto from a language because sometimes people abuse it and write spaghetti. C++ has operator overloading. D has alias this. If (for example) a DSL is the appropriate tool then being able to use macros to integrate it seamlessly into the host language is a good thing. |
|
Right, but the temptation to do it is irresistible.
> That's Doing It Wrong™
Of course it's doing it wrong. The point is, that seems to always happen because the temptation is irresistible.
> goto
I rarely see a goto anymore. It just doesn't have the temptation that macros do.
> alias this
Has turned out to be a mistake.
> integrate it seamlessly into the host language is a good thing
Supporting the creation of embedded DSLs is a good thing. Hijacking the syntax of the language to create your own language is a bad thing. I've seen it over and over, it never works out very well. It's one of those things you just have to experience to realize it.
D's support for DSLs comes from its ability to manipulate string literals at compile time, generate new strings, and mixin those strings into the code. This is clearly distinguishable in the source code from ASTs.