Re: OO versus RDB
Date: 9 Jul 2006 13:58:23 -0700
Oh, certainly. The interesting question in my mind is how does one distinguish observable effects that matter from those that don't matter? Sometimes one introduces a write into a function or procedure or whatever-you-want-to-call-it, solely for the purposes of seeing when it is actually invoked; if doing so triggers a host of changes in how the function is treated, this defeats the purpose. On the other hand, perhaps sometimes an output is intended to occur regardless of whether the enclosing expression might otherwise be optimized away. It is my suspicion that much more output falls in to the first category than the second than is typically appreciated, but it is only a suspicion at this time.
> Thus, such a function is not a pure function according
> to the definitions I have seen.
I have not observed that the use of "referential transparency" and "purity" is entirely consistent. If we go by what wikipedia says at the time of this writing, referential transparency means side-effect-free and pure, side-effect-free means no outputs other than return values, pure means return values depend solely on parameters.
I also find it funny that *all* outputs are called "side-effects" regardless of whether they are of primary concern or not: it seems disingenuous to me to call the fact that "printf("hello, world\n");" writes to standard out a *side* effect. I mean, what is it to the side *of*?
> Now, if the variable were a static variable not
> observable outside the function, then it would be pure.
Yes, this gets at another point that is often glossed over: what is an observable effect is entirely dependent on context. Since that's true, it means that if we go by the above definitions, then if we have a pure function, whether it is referentially transparent is a matter of context! We could for example have an entirely pure program that performs no output (only returning a value at exit) and be able to run it on a virtual machine that writes to a log file at every function entry point. Is it referentially transparent? From the viewpoint of the program itself, yes; from the viewpoint of the entire system, no. However if you point out to people that their definition of referential transparency is context dependent, some of them will get very angry.
The fact that raising these points gets so many people so riled up indicates to me that not everyone is thinking entirely clearly about the issues, and that indicates that there are opportunities to advance the state of the art.
Marshall Received on Sun Jul 09 2006 - 22:58:23 CEST