Boost logo

Boost :

From: David Bergman (davidb_at_[hidden])
Date: 2003-10-21 12:01:50


> "David Bergman" <davidb_at_[hidden]> writes:
>
> > It has to do with purity, that Haskell is a pure language
> in the sense
> > of an expression ALWAYS evaluating to the same value, so
> that the same
> > exact expression can be substituted for that computed value
> wherever, whenever.
>
> Even I can tell that has no bearing on side-effects, though:
>
> int z;
> int f(int x) { return z = x; }
>
> f(y) is always y for any y
> still, it has side-effects.

Actually, you are wrong (even though this has nothing to do with the purity
of a language, since C++ is not pure...)

The mistake you make is twofold:

(1) The result of a computation is the canonical representation (read
"numerical value" in this case)
        
        z = <n>: f(z) = <n>, which clearly varies as the value stored in 'z'
varies... so, not the same at all

(2) Even in your more syntactical view of things ("f(y) is always y"), that
argument is wrong

        z = any value, say 42 : f(z+1) = 42+1=43, (after previous
evaluation) z+1 = 43+1=44, not the same

/David


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk