
15 Dec
2020
15 Dec
'20
5:05 p.m.
Dear Cafe, In code of the form case as ++ bs of [] -> ... x:xs -> ... under what circumstances is the overhead of cons-cell creation for the elements of `as` that would happen in an eager language avoided? Always? Is the answer the same if `f` is defined by simple list recursion and we call `f (as ++ bs)`? What if `f` is defined in a different module (or comes from the Prelude)? I know that questions of this type can be answered in specific cases by looking at the (intermediate) code generated by the compiler, but more generally, are there some succinct principles that everyday programmers can hang on their cubicle walls that summarize a lot of what they can expect from the compiler in terms of optimizations? Todd Wilson