Metaprogramming in D : Some Real-world Examples

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Nov 12 07:53:35 PST 2009


Bill Baxter wrote:
> On Mon, Nov 9, 2009 at 6:03 PM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> Bill Baxter wrote:
>>> On Mon, Nov 9, 2009 at 4:09 PM, Walter Bright
>>> <newshound1 at digitalmars.com> wrote:
>>>> Looks like Bill Baxter is giving a presentation on D Nov. 18!
>>>>
>>>> http://www.nwcpp.org/
>>> Yep, that's right, and I'd be quite grateful to you smart folks here
>>> if you could share your meta-programming favorites with me!   If
>>> you've got a real-world example of meta-programming in D that you
>>> think is particularly handy, then please send it my way
>>>
>>> I'm looking for small-but-useful things that are easy to explain, and
>>> make something easier than it would be otherwise.  Things like places
>>> where static if can save your butt,  or loop unrolling,  and passing
>>> code snippets to functions like in std.algorithm.
>>>
>>> Things like a compile-time raytracer or regexp parser (though quite
>>> cool!) are not what I'm after.  Too involved for a short talk.
>>>
>>> --bb
>> std.random has code that checks the parameters of a congruential RNG during
>> compilation. That's also an example in TDPL.
> 
> This looks good.
> Any chance you could send me the snippet of the book that explains the
> rationale for what constitutes "proper linear congruential
> parameters"?
> 
> --bb

It's been online for a while.

http://erdani.com/tdpl/excerpt.pdf


Andrei


More information about the Digitalmars-d-announce mailing list