There's an issue <https://github.com/JuliaLang/julia/pull/12205> on Github 
to add GC support for stack-allocated objects, and that makes no sense to 
me! Could someone please help me out? In my mind, stack-allocated objects = 
Int+Float+...+Immutable (in some circumstances). I thought that with 
Immutables, if I have

immutable ImagePos
   img::Image
   x::Int
   y::Int
end

function blah(img)
   a = ImagePos(img, 10, 20)
   foo(a)
   l = Any[40, a]
end

then `a` is stack-allocated. The foo(a) call may either copy `a` further, 
or just pass on a stack pointer to the existing `a`, depending on compiler 
details. Any stack-allocated object gets automatically wiped as the stack 
unwinds, hence does not need GC'ing.

Then on the `l` line, because it's an Any array, the ImagePos needs to be 
copied, boxed and heap-allocated. So that one needs GC.

What did I miss?

Cédric

Reply via email to