Can a compiler automatically detect pure functions without the type information about purity?
So I'm arguing with my friend who claims that a compiler like GCC can detect a pure function automatically without any type information. I doubt that. Languages like D or Haskell have purity in their type systems and a programmer explicitly defines what function is pure or not. A pure function has no side effects and can therefore very easily be parallelized. So the question is: Is this all necessary or not? Could a compiler detect purity, without any meta or type information, just by assuming that anything that does IO or accesses global variables automatically is not pure? Sure, you can