Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Usenet -> comp.databases.theory -> Re: Does Codd's view of a relational database differ from that ofDate&Darwin?[M.Gittens]

Re: Does Codd's view of a relational database differ from that ofDate&Darwin?[M.Gittens]

From: Marshall Spight <>
Date: 24 Jun 2005 18:01:08 -0700
Message-ID: <>

vc wrote:
> Marshall Spight wrote:
> >
> [...]
> > At the same time, there's a common meme that says that "side effects"
> > (often meaning either access to global variables or I/O) necessarily
> > destroy referential transparency, but that's dicey at best. It doesn't
> > distinguish between input/read vs. output/write, and the distinction
> > is huge. In essence, a function can output to streams or update
> > globals all it wants and it will not alter the return value of the
> > function.
> Suppose we have a function f(a) defined as returning 2*a. Given the
> expression x=f(a);x+x we can rewrite it as f(a) + f(a). Now, let's
> assume that f(a) in addition to doubling its argument prints it. We
> cannot transform the original expression any more because the argument
> would be printed twice, the program behaviour would change.

"Referential transparency: In computer programming, a referentially transparent function is one that, given the same parameter(s), always returns the same result."

So what are you testing the referential transparency of, f or the program? In your example, the return value of f(a) was defined as 2*a, which it will be, whether f() prints or not. So f is referentially transparent, by definition.

If you want to expand the definition of function such that its outputs include the state of all global variables and all output streams, then it would no longer meet the definition, but you'd have to then say that the definition of f() is "append X to the printer stream and return 2*a." I don't think such a definition would be very useful, but maybe it would be in the right context.

The further problem then comes with the fact that your program can't know whether it's running on a virtual machine of some kind, and perhaps that virtual machine calls a print function each time a method is called. With the expanded definition of function, it is impossible to know what the outputs of a function are without considering not only the function but the machine it is running on. Of course, *that* machine could be running on a virtual machine, so you have to talk that into account as well.


> > In other words, if we regard print as a function and consider the
> > activation of the physical printer to be a side effect, then print
> > is still referentially transparent.
> No, it is not.

Marshall Received on Fri Jun 24 2005 - 20:01:08 CDT

Original text of this message