Compile time metaprogramming
Jonathan M Davis
jmdavisProg at gmx.com
Fri Dec 2 14:28:26 PST 2011
On Friday, December 02, 2011 22:00:44 simendsjo wrote:
> I had a little talk with one of my teachers regarding the culprits of
> wrong unit assumptions in code
> (http://mars.jpl.nasa.gov/msp98/news/mco990930.html).
>
> We had a little different views on how much pain it would be for
> developers to code using an SI library, so I hacked together a small
> proof-of-concept in D to show how D's metaprogramming could make things
> a lot less painful than, say, Java.
>
> I thought I could share it here too even though it's just a small hack
> with Norwegian comments.
A unit library is definitely a great place for taking advantage of templates -
that's what core.time and std.datetime do with time units (e.g.
dur!"seconds"(5)). There's also been at least a couple of cases where people
have worked on unit libraries and discussed them in the main newsgroup, but so
far, nothing has gotten to the point where it's been reviewed for introduction
to Phobos, and I don't know if any of those projects is still alive. It would
definitely be an asset though.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list