Implementing Pure Functions

Kagamin spam at here.lot
Thu Jun 16 04:07:09 PDT 2011


Walter Bright Wrote:

> http://drdobbs.com/blogs/tools/230700070

import std.stdio;

int square_debug(int x)
{
    writefln("square(%d)", x);
    return x * x;
}

pure alias int function(int) fp_t;

pure int square(int x)
{
    auto fp = cast(fp_t)&square_debug;
    return (*fp)(x); // dereference???
}


More information about the Digitalmars-d mailing list