Re: OO versus RDB
Date: Fri, 07 Jul 2006 16:55:19 +0100
Message-ID: <M5mdnd6NGMlyHjPZnZ2dnUVZ8tKdnZ2d_at_giganews.com>
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 :-)
Such a "function" isn't a function at all, 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. 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.
Regards
-- Adrian HeyReceived on Fri Jul 07 2006 - 17:55:19 CEST