Just an example, why D rocks, and C++ s***s...

Dukc ajieskola at gmail.com
Mon Mar 21 16:07:44 UTC 2022


On Monday, 21 March 2022 at 15:23:21 UTC, Ola Fosheim Grøstad 
wrote:
> Does anyone have a list of usage scenarios for compile time 
> strings without string mixins that would motivate a programmer 
> to shift to another language to get it?

Stealing a bit of Symmetry Investments prototype code I'm 
currently working on to demonstrate.

```d
template addMonthsStick(DateType) {
     @SILdoc("Adds m number of months"
         ~ " to a " ~ __traits(identifier, DateType)
         ~ "[snip the rest of doc description]"
     )
     DateType addMonthsStick(DateType arg, long m) {/*...*/}
}
```

IOW, generating documentation for Symmetry Integration Language 
function at compile time.

Also, https://code.dlang.org/packages/pegged. While it works with 
string mixins, you can also make a separate program to generate 
the parser for your main project. That way you avoid having the 
compiler processing the PEG over and over again at compile time.


More information about the Digitalmars-d mailing list