
On 9/6/06, Alex Queiroz
Hallo,
On 9/6/06, Lennart Augustsson
wrote: Furthermore, doing that optimization (common subexpression elimination) can lead to space leaks. So you should not count on the compiler doing it. Besides, I often find it more readable and less error prone to name a common subexpression; only one place to change when you need to change the call.
So there is no benefits from the "functions have no side-effects" property, performance-wise. Pity.
I think most compilers actually do CSE (to varying extents), but it's not a good idea to rely on it since nobody will ever *guarantee* that it's done. Purely functional does give you some performance benefits, though. Such as getting pass-by-reference performance "for free" (i.e. without actually having to worry about pass-by-reference semantics -- send a huge data structure "by value" to a function and it will really only be a pointer that gets sent). You can also do parallel and other multithreading stuff much easier which should surely count as a major performance benefit. /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862