Even if `println` returned a value, it would still be considered pure as long as that value is strictly calculated from its input parameter and that parameter alone (say, the size of the string).
Another often used criterion to determine purity of a function is whether inlining it everywhere in your program produces a similar program. There again, `println` passes this test.
The only way `println` could not be pure is if you call it with the same string twice and it returns a different value.
var a = println("Hello ")
a = println(" World")
This should output "Hello \n World\n"
However, assuming println is pure, we can optimize this to just var a = println(" World")
Which produces a different output. We could also convert: var a=println("Hello")
var b=println("Hello")
into var a=println("Hello")
var b=aWhat 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.
In Haskell, all functions in the IO monad are by definition pure, and that includes all the println functions.
Yes the relationship between input and output is clearly defined, though. Your point of view raises a good point about precision when talking about purity and functions.