Google Groups

Re: Magic incantations and immutable arrays


Patrick O'Leary Apr 26, 2012 1:35 PM
Posted in group: julia-dev
On Thursday, April 26, 2012 3:23:17 PM UTC-5, Toivo Henningsson wrote:
On Apr 26, 11:03 am, Stefan Karpinski <ste...@karpinski.org> wrote:
> If this kind of kernel requires immutable arrays, I would generally
> recommend not mutating your arrays while performing such magic :-)

Now that I think about it, complete immutability might be a bit too
harsh.
It would probably be better for me to denote an Array as frozen for
some interval of time.
This of course requires some care from the programmer, but that's
maybe not such an unreasonable thing to demand as I first thought :)

If anyone's interested, I made a small sketch here:
https://gist.github.com/2502738

The idea is to do
A = freeze(A)
# A is now a Frozen{Array} that holds the original A
do stuff...
A = unfreeze(A) # notify all interested and return original A

or equivalently

@freeze A begin
    do stuff...
end

This looks like a concurrency problem waiting to happen, unless I'm missing something.