Implementing Pure Functions
Jimmy Cao
jcao219 at gmail.com
Thu Jun 16 04:20:40 PDT 2011
On Thu, Jun 16, 2011 at 6:07 AM, Kagamin <spam at here.lot> wrote:
> 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???
> }
>
Yes, that's correct.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110616/486dbf47/attachment.html>
More information about the Digitalmars-d
mailing list