My (quite possibly wrong) understanding is that purity has nothing to say about side effects. It's simply concerned with the inputs and outputs of functions, specifically whether the function will always return the same value given the same input.
What zak_mc_kracken is saying is that under this definition println is obviously and trivially pure because it returns the same value for every input.
You're correct that it won't have the proper side effects when optimized but under this definition that doesn't have anything to do with purity.
Edit:
If you want the "side effects" of the println statement to be considered part of the "output" then you want something like Haskell's semantics where the println statements are IO actions.
You are correct under this particular interpretation of purity, there are just competing ways to assess said purity. Wikipedia only lists two (the one you just showed and the one I described) but is missing the third one (the inlining approach).
In Haskell, all functions in the IO monad are by definition pure, and that includes all the println functions.
Comments
Consider the following program.
This should output "Hello \n World\n" However, assuming println is pure, we can optimize this to just Which produces a different output. We could also convert: intoMy (quite possibly wrong) understanding is that purity has nothing to say about side effects. It's simply concerned with the inputs and outputs of functions, specifically whether the function will always return the same value given the same input.
What zak_mc_kracken is saying is that under this definition println is obviously and trivially pure because it returns the same value for every input.
You're correct that it won't have the proper side effects when optimized but under this definition that doesn't have anything to do with purity.
Edit: If you want the "side effects" of the println statement to be considered part of the "output" then you want something like Haskell's semantics where the println statements are IO actions.
Edit: zak_mc_kracken beat me to it.
You are correct under this particular interpretation of purity, there are just competing ways to assess said purity. Wikipedia only lists two (the one you just showed and the one I described) but is missing the third one (the inlining approach).
In Haskell, all functions in the IO monad are by definition pure, and that includes all the println functions.