Dan Doel dan.doel at gmail.com
Wed Aug 11 15:40:43 EDT 2010

```On Wednesday 11 August 2010 3:13:56 pm Tillmann Rendel wrote:
> I understand your argument to be the following: Functional languages are
> built upon the lambda calculus, so a *pure* functional language has to
> preserve the equational theory of the lambda calculus, including, for
> example, beta reduction. But since BASIC or C are not built upon any
> formal calculus with an equational theory, there is not notion of purity
> for these languages.

In the discussion from #haskell I mentioned, some folks argued that BASIC was
pure because there was no equivalent of Haskell's evaluation, only execution.
I was just attempting to translate that to a more Sabry-like explanation,
where there would be an empty (or otherwise trivial) sublanguage, and so
purity would be trivial, because evaluation does nothing (or something along
those lines).

> I like your definition of purity, but I disagree with respect to your
> evaluation of BASIC and C. To me, they seem to be built upon the formal
> language of arithmetic expressions, so they should, to be "pure
> arithmetic expression languages", adhere to such equations as the
> commutative law for integers.
>
>    forall x y : integer, x + y = y + x
>
> But due to possible side effects of x and y, languages like BASIC and C
> do not adhere to this, and many other laws. I would therefore consider
> them impure. They could be more pure by allowing side effects only in
> statements, but not in expressions.

I'm no BASIC expert, but they were talking about very rudimentary BASICs. The
sort where line numbers and GOTO are your control flow, not even subroutines.
I'm not sure if that affects your point here or not.

Certainly, if you consider numeric arithmetic to be the core language, C is an
impure extension of it (the #haskell folks weren't actually arguing that C was
pure; just the simple BASIC). Not sure about the above BASIC, but a fancier
BASIC would be, in the same way.

-- Dan
```