Open source dmd on Reddit!

Don nospam at nospam.com
Mon Mar 9 01:03:38 PDT 2009


Nick Sabalausky wrote:
> "dsimcha" <dsimcha at yahoo.com> wrote in message 
> news:got0ff$28r4$1 at digitalmars.com...
>> == Quote from grauzone (none at example.net)'s article
>>> String mixins are awful in the first place. The only thing that could
>>> save this kind of thing are AST macros.
> 
> Both Murphey's law and the law of D bitfields dictate that we're all going 
> to end up hating AST macros when they finally show up ;)
> 
>> ????????????? String mixins are an absolute godsend.  I mean really, how 
>> much more
>> general a metaprogramming facility could you possibly ask for than the 
>> ability to
>> generate arbitrary D code at compile time?  Of course they can get ugly, 
>> so there
>> should be better ways to do things that are done frequently (regular 
>> templates
>> accomplish this), but last I checked, bit fields are not an everyday
>> run-of-the-mill programming type of feature.
>>
>> As a more general comment, of course syntax and readability count for 
>> frequently
>> used features, but there's only so much pretty syntax available, and 
>> simplicity of
>> the core language is a virtue.  If certain things in D are going to have 
>> ugly
>> syntax, they may as well be niche features like bit fields.
> 
> My thought is that it's absolutely great to have string mixins, but they 
> should never be thought of as anything more than a clumbsy substitute 
> (athough notably less clumbsy than a preprocessor macro) for a real language 
> feature to accomplish the same task (or possibly an AST macro). 
> 
> 
Sure, they're open to _severe_ abuse, but for the case when they are 
used to generate source code (eg, from a DSL), they are absolutely 
perfect, and not a hack at all. In that particular scenario, they are 
much better than AST macros could ever be.

They're a replacement for creating a text file, adding a line to your 
makefile in order to invoke a program to read the text file and spit out 
a d source file, then add another line in the makefile to compile that d 
file, then link it in, and try to integrate the whole thing seamlessly. 
They're a beautiful solution to a really ugly problem.

It's not fair to regard them simply as a hack to get around language 
limitations.


More information about the Digitalmars-d-announce mailing list