On Sat, 24 May 2014 11:42:30 +0000 HaraldZealot via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> The logger is very good and need thing. But has anybody an idea > how to preserve purity of functions? > That's impossible if you're doing I/O. By definition, that has to access mutable, global state. The only way to do it would be to go the Haskell route and use something like monads - you'd have to basically pass an object around which built up the logging messages without actually logging anything and then have an impure function higher up (which is calling these pure functions) make the function call which actually caused the queued up logging to be output. Logging is basically anti-purity. So, unless you do something like I just described (which I doubt much of anyone will), then logging anything in your code means giving up purity. - Jonathan M Davis