Re: OO versus RDB

From: Marshall <marshall.spight_at_gmail.com>
Date: 7 Jul 2006 14:52:35 -0700
Message-ID: <1152309155.826119.51120_at_b28g2000cwb.googlegroups.com>


Adrian Hey wrote:
> Marshall wrote:
> > Heh. Funny you should mention that. It's also the case that
> > one can have a function that writes to global variables
> > but doesn't *read* from them, and it will *still* be
> > pure, in that the outputs depend only on the inputs.
> >
> > The functional guys *really* hate it when I say *that*.
>
> Well maybe that's because you're wrong :-)

Piffle. I'm not much interested in any dogmatic definition of terms. What I said is true: a function that doesn't read any external variables but does write to them will have its return value entirely determined by its parameters. Don't like it? Take it up with God and Euclid.

> Such a "function" isn't a function at all,

It meets the mathematical definition, and also the commonly used programming definition.

> and common program
> transformations and compiler optimisations (e.g. common sub-expression
> elimination) will modify/break programs in such cases.
>
> Basically, in order to be considered "pure" it is necessary but
> not sufficient that the result delivered by a function is dependent
> only on the values of it's arguments. It's also necessary that
> evaluation has no other observable effect.

This is just arguing about what the definition of the term "pure" ought to be. Not very interesting.

Does knowing that a function that only writes to variables but doesn't read to them has its return value determined only by its inputs help us reason about program behavior? Sure it does. I don't care what name you give it.

> So a programs observable
> behavior is identical whether the same expression is evaluated just
> once or several times (or maybe not at all) and is also independent
> of evaluation order.

You want to focus on observable behavior, that's fine by me. Be sure to track power consumption and heat generation, though, because those are both observable behavior. Me, I want to focus on return values. Primary effects are more important than side effects; that's why they have the names that they do.

Marshall Received on Fri Jul 07 2006 - 23:52:35 CEST

Original text of this message