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

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Mar 21 19:33:15 UTC 2022


On Monday, 21 March 2022 at 16:07:44 UTC, Dukc wrote:
> ```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.

Ok, so you use it to access reflection within the compiler 
instead of using "compiler as a library".

> 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.

Not sure why you would do this as a compile time evaluation if 
you run it separately anyway?

Both these use cases are what I would consider "auxiliary usage" 
and not so much relevant for building libraries IMO, although 
being able to extract information using reflection is nice 
workaround if you don't have access to an "compiler as a library" 
feature.




More information about the Digitalmars-d mailing list