-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shape-frozen and value-frozen collections #1
Comments
I agree, there are a lot of possible behaviors a container could expose. I think these need to be thought through in detail. I like the genericness of One of my immediate goals here are to investigate the idea of having all the "functional" operations in function f(a::AbstractArray)
...
out = similar(a, newtype, newsize)
f!(a)
return freeze(a)
end The user will normally not want to mutate the output of The point is here is that construction of new immutable containers can be very challenging without mind-bending and compiler-heavy techniques (e.g. complex recursion or generated functions). Whereas filling the values incrementally with a mutating, procedural technique is usually very easy (it is usually easy to implement Now we don't yet have proper support for immutable And finally you would know better than me (from BangBang.jl) that the hard bit here is actually computing |
(Yay, I got #1! 😄) Hmm... Implementing As you might have guessed, my preference for writing generic functions is to define [*] It does not mean I'm against
I think the main obstacle here is not the data sink but rather the data source; it's just that the BTW, my interest on frozen collections is more about immutable shared keys of dictionaries and shared indices of subarrays and sparse arrays. (Also shape-immutable vectors for table columns.) [**] "Friendly" in the sense that it dumps much more information to the compiler which has to work harder to consume it. So, yeah, it's still compiler-heavy. |
OK so I committed the random functions I've been tweaking and put it in a repository https://github.com/tkf/Mutabilities.jl. It has similar |
Continuing discussion JuliaArrays/StaticArrays.jl#745 (comment)
Yes, exactly my thought. It'd be great if we can freeze/thaw
push!
-ability andsetindex!
-ability separately.FYI, I'm using internal "trait" functions like
implements(f!, T)
andpossible(f!, args...)
in BangBang.jl as I don't want to keep introducing new trait functions. A similar approach could be useful if you want to distinguish append-only, FIFO, LIFO, etc. But maybe this kind of generality is not appropriate at this stage of design.As for the naming, I think it'd be nice if "shape freezing/thawing" for vectors and dictionaries can be done with a same interface. I was thinking something like
ismutablevalue
andismutableindex
but I think "keys" instead of "index" is also fine sincekeys
is implemented for arrays.The text was updated successfully, but these errors were encountered: