Thanks, that's great! Maybe this should make it to upstream julia. Fixed-size arrays are essential to get good performance, and compact memory usage.
------------------------------------------ Carlos On Wed, May 7, 2014 at 5:46 PM, Tobias Knopp <tobias.kn...@googlemail.com>wrote: > see https://github.com/JuliaLang/julia/issues/5857. I have been using > ImmutableArrays.jl which works fine. > > Am Mittwoch, 7. Mai 2014 17:12:04 UTC+2 schrieb Carlos Becker: > >> Hello, I am trying to find out the best way to deal with immutables (or >> types) that contain fixed-size arrays, such as this: >> >> # should have variable number of >> >> # Uint64's >> >> immutable Descriptor >> >> a1::Uint64 >> >> >> a2::Uint64 >> >> a3::Uint64 >> >> a4::Uint64 >> >> end >> >> # should work with variable-size Descriptor >> >> function myDist(x1::Descriptor,x2::Descriptor) :inline >> >> return count_ones(x1.a1 $ x2.a1) + count_ones(x1.a2 $ x2.a2) + >> count_ones(x1.a3 $ x2.a3) + count_ones(x1.a4 $ x2.a4) >> >> end >> >> >> >> In this specific case, Descriptor is 32-bytes wide, but I would like to >> make the code generic for different number of elements in the immutable. >> If fixed-size arrays were available, this would be very easy, but which >> is a neat way of doing this with the current julia v0.3? >> >> btw, the code above runs amazingly fast, using popcount instructions when >> available, almost c-speed ;) >> This is good news for Julia indeed. >> >> Thanks. >> >