Skip to main content
11 events
when toggle format what by license comment
May 1, 2016 at 19:27 comment added njzk2 @DeadMG in many systems, the logging system can be swapped for another without the program even knowing. So no, you can't rely too much on it.
May 1, 2016 at 16:06 comment added Steve Jessop It's a matter of whether you choose to define the logger to be part of the execution environment or not. For another example, is my pure function still pure if I attach a debugger to the process and set a breakpoint on it? From the POV of the person using the debugger, clearly the function has side-effects, but normally we analyse a program with the convention that this "doesn't count". The same can (but needn't) go for logging used for debugging, which I presume is why trace is hiding its impurity. Mission-critical logging, e.g. for audit, of course is a significant side-effect.
May 1, 2016 at 15:27 comment added Andres F. (PS: take a look at Haskell's trace, which makes it clear adding logging to a function makes it not referentially transparent, and therefore (by Haskell's definition) impure. trace is a dangerous function because it "hides" this impurity from the function's signature, which is in general a no-no).
May 1, 2016 at 14:34 comment added Andres F. This means that "the number of times the function was called" is an observable property of your program's behavior. Therefore, the two programs do not behave the same!
May 1, 2016 at 13:00 comment added DeadMG Your logging library should guarantee no deadlocks. Otherwise, you really need a new one.
May 1, 2016 at 8:55 comment added Basilevs Should I carry on if function deadlocks? Is not dependent?
May 1, 2016 at 8:52 comment added DeadMG @Basilevs The behaviour of the function isn't dependent on them at all. If the log write fails, you just carry right on.
May 1, 2016 at 8:52 comment added DeadMG @AndresF. Well, you probably don't care about the literal number of times. You probably only care that it's logged as many times as the function was called.
May 1, 2016 at 7:41 comment added Basilevs -1 Logs do matter. On most platforms output of any kind implicitly synchronizes execution thread. Behaviour of your program becomes dependent on other threads writes, on external log writers, sometimes on log reads, on state of file descriptors. It is as pure as bucket of dirt.
Apr 30, 2016 at 22:57 comment added Andres F. Well, it depends. Maybe the logs make it impure, for example if you care about how many times, and at what times, "INFO f() called" appears in your log. Which you often do :)
Apr 30, 2016 at 21:36 history answered DeadMG CC BY-SA 3.0