Grafting Functional Support on Top of an Imperative Language

Brian Palmer d at brian.codekitchen.net
Fri Apr 4 22:20:26 PDT 2008


Jason House Wrote:

> bearophile wrote:
> > P. 31: >writeln(i);<
> > 
> > Can you put (temporary) debugging writeln/putr inside a pure function?
> 
> That's always bothered me about this stuff.  I don't want to lose
> debugging/logging ability!

This seems like a non-issue to me. Even Haskell, one of the "purest of the pure", so to speak, has the unsafePerformIO "back door" to allow just these kind of idempotent side effects. I'm sure D will have the same. The trade-off, of course, is that once you decide to sneak in the back door, it's up to you to verify that your debug statements or whatever truly don't have any affect on the rest of the application, because at that point you've given up all compiler promises.

D would probably implement it as a simple "cast" on functions from non-pure to pure, much of the issues that arise in Haskell's back door don't apply to D because of lazy vs. eager evaluation, etc.



More information about the Digitalmars-d mailing list