Suggestion/proposal regarding std.logger candidate
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 24 23:56:39 PDT 2014
On Sat, 24 May 2014 20:10:21 -0700, Jonathan M Davis via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Sat, 24 May 2014 11:42:30 +0000
> HaraldZealot via Digitalmars-d <digitalmars-d at 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.
IIRC, logging with 'debug' should work.
-Steve
More information about the Digitalmars-d
mailing list