I imagine that a function specifically for this, eg named fillwith or similar, would be a useful addition to Base. I thought I saw some discussion about this an issue, but I cannot find it.
I have never used the resize! function directly but the idea of a copy keyword would make a lot of sense for fill. I.e. fill([], 2, copy=true) could make an array with distinct empty arrays.
Beside already mentioned problem with defining an array of functions (which is somewhat contrived, as functions defined via function or -> have singleton types), there is a worse one: what if someone makes a callable struct subtyping Function? E.g.:
struct Id{T} <: Function
value::T
end
(x::Id)() = x.value
Why should fill(Id(0), k) return an array of zeros and not an array of Ids?
Ah, my bad, only looked at functions with no captured variables.
Then, I’d better say “an idea of array of functions may seem contrived, but in Julia it’s not uncommon to create entities that may be viewed as both function and data objects”.