3 ms·
> Purity is not on a scale. Either a language is pure, or it isn't. This is not quite right. "Purity" mean that with respect to some unspecified by fine-grain
by tome 6y ago
> Purity is not on a scale. Either a language is pure, or it isn't.
This is not quite right. "Purity" mean that with respect to some unspecified by fine-grained semantics various pairs of programs are equivalent. For example, in the denotational semantics of Haskell the following are equivalent
let x1 = rhs
x2 = rhs
in body
and
let x = rhs
x1 = x
x2 = x
in body
But they are not equivalent under the operational semantics. The former allocates two closures, the latter one. The "scale" of purity then is measured by how fine-grained the semantics is. Haskell is pure at the "scale" of denotational semantics, but not at the scale of operational semantics.
- DonaldPShimoda 6y agoOoh I had not heard "purity" defined this way previously in such explicit detail, but it makes perfect sense and I really really like it. Thank you so much for giving me better words for this going forward! Edit: I think, though, that my point kind of still stands in that, with respect to a specific level of semantic detail, a language is either pure or it isn't. Further, I think it isn't useful to compare Language A at Semantic Level 3 to Language B at Semantic Level 1 to compare purity; you're generally going to be sticking to one level of semantic detail at a time, and within that lens all languages will either be pure or impure. Right? Hmm maybe I need to think on this more.