Open
Description
I've seen freeze(x)
and thaw(x)
thrown around for making x
immutable and mutable, respectively. I'm not sure if we should wait for base to formalize the ImmutableArray
approach, or if it's worth have some common syntax for that right now. I'm not sure if we're ever going to get much petter than this pattern:
function foo(x)
y = similar(x)
foo!(y, x)
if ismutable(x)
return y
else
return freeze(y)
end
end
# change values of `y`
foo!(y, x) = ...
Which might be fine if we can ensure that freeze(y)
and similar(x)
are close so that the compiler can easily figure out what to allocate to the stack and elide unnecessary allocations.
Metadata
Metadata
Assignees
Labels
No labels