Re:An Experiment in Purely Functional IO for Clojure
by badsock on Sunday April 19, 2015 @02:57AM
(#9402277)
Ah, but
println "Hi there"
doesn't return nil, it returns a value of the type IO nil
which can be transparently substituted for the call.
This is clearly the case with `println`.
is clearly not the same program as as the former causes output to the console, while the latter does not -- an observable difference.Using Scheme (because I don't know Clojure that well)
is a referentially transparent program. Although it contains a side-effect (the assignment to y) this effect is not observable outside `foo`, and thus any call to `foo` can be substituted with its result.