3 ms·
I never quite understood Uday's objection. Any language can be referentially transparent if you consider it's denotation to be just its syntax. Then you can a
by tome 5y ago
I never quite understood Uday's objection. Any language can be referentially transparent if you consider it's denotation to be just its syntax. Then you can always replace equals with equals, but the only thing equal to an expression is the exact same sequence of characters! The whole point is to be referentially transparent with respect to as coarse a semantics as possible. Haskell gets some of the way there, yet even
let x = e
y = e
in ...
is not equivalent to
let x = e
y = x
in ...
if your semantics can distinguish expressions by the time they take to evaluate.
Still (to address your original question) people do consider lambda calculi with effects, so if the expression-based fragment of an imperative language supports lambdas with lexical scoping then sure you could get away with saying that "their expression are based on lambda calculus".
- kaba0 5y agoI’m having a “debate” about it at another thread as well, so let me just point to a perhaps better explanation: https://elarib.com/item?id=22141647 https://elarib.com/item?id=22141647 So taking eg. Template Haskell, you actually loose referential transparency since then even the syntax itself matters and you can’t just replace it to an equivalent expression. I have no experience with Template Haskell itself so bare with me, but eg. having a macro m that converts the constant 2 to the string “two” while others to empty string will fail to be referentially transparent since `m 2` will not be the same as `let a = 2 in m a`.
- tome 5y agoFirstly, I'm not sure you can even write that in Template Haskell. The syntax would actually be let a = 2 in $(m a) and since `a` is not in scope at the time the TH splice runs compilation will fail. Secondly, even if you could write it, I don't really think something that contains Template Haskell should be called a "Haskell expression". With regard to pron's comment, he has a long history of being technically correct with regard to Haskell. The operative point is > What they mean is that the language is referentially transparent (like most language) and a term's reference (denotation) is an object value in the language i.e. Haskell is referentially transparent with respect to a particularly coarse semantics (value semantics). Anyway, your greater point that referential transparency doesn't imply immutability is completely correct.