Array module empty array return values

Coordinator
Dec 19, 2014 at 11:04 PM
I think we missed this when code reviewing the collections API PRs, but want to confirm/discuss.
  • For F# 3.1 (and I assume earlier), all arrays returned from the various Array module functions were freshly allocated, including empty arrays. The singleton [| |] / Array.empty is never returned from a processing function.
  • For some of the F# 4.0 APIs, optimizations/shortcuts/special cases were used which return the singleton instance when it’s known that the result will be an empty array.
Should these new guys all be “fixed” to return a fresh empty array? Although it seems safe/optimized to use a singleton, even for arrays, my hunch is that this pattern is intentional.
Coordinator
Dec 20, 2014 at 2:31 AM
I think they do not need fixing. Not allocating a fresh empty array seems like the right thing.