I just got my copy of Expert F# 2.0 and came across this statement, which somewhat surprised me:
For example, when necessary, you can use side effects on private data structures allocated at the start of an algorithm and then discard these data structures before returning a result; the overall result is then effectively a side-effect-free function. One example of separation from the F# library is the library's implementation of List.map, which uses mutation internally; the writes occur on an internal, separated data structure that no other code can access.
Now, obviously the advantage to this approach is performance. I'm just curious if there are any disadvantages--do any of the pitfalls that can come with side-effects apply here? Is parallelisibility affected?
In other words, if performance were set aside, would it be preferable to implement List.map
in a pure way?
(Obviously this deals with F# in particular, but I'm also curious about general philosophy)