Pure functions in D

Sean Kelly sean at invisibleduck.org
Mon Sep 29 14:57:37 PDT 2008


== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> Regarding the pure function topic: is it possible to have, just at debug time, the possibility to add special
debugging printing statements into pure functions? :-)
> Maybe now I am asking something silly... because the order of their prints and the number of times such
function is called isn't defined by the compiler, and it may even change.
> Another possible way to debug is for the programmer to temporary remove the "pure" statement(s), add
some debugging writefln/putr/stdios, compile, run, see the output, put the "pure"(s) back, etc, etc... :-)

Monads ;-)  Otherwise, something like this should work:

void debugln_(...) { /* forward to writefln */ }
alias pure void function(...) SomeFn;
SomeFn debugln = cast(pure SomeFn) &debugln_;


Sean



More information about the Digitalmars-d mailing list