How about exploiting the zero size Nothing type?
immutable MyType{A, B, C, D, E}
a::A
b::B
c::C
d::D
e::E
end
If you construct this as
all_params(nothing, nothing, c, nothing, e)
You will get a type with only 2 fields that take space. The 3 fields of
type Nothing takes up
Yeah, I've been thinking about this – and I'm actually using it for one of
my fields at the moment. Some of the other fields have type parameters
themselves, such as NTuples with lengths, etc., so this would be a
two-level thing, then. I couldn't supply the size of a tuple in this type
if
Sorry, I seem to have been wrong. Nothing/nothing works that way with
arrays, so I assumed it worked the same way with types. It seems like it
does not and uses a lower bound of 8 for empty immutables.
It is probably simple to fix, I'll open an issue.
Ivar
kl. 13:29:48 UTC+2 onsdag 27. august
See: https://github.com/JuliaLang/julia/issues/8156
kl. 14:03:55 UTC+2 onsdag 27. august 2014 skrev Ivar Nesje følgende:
Sorry, I seem to have been wrong. Nothing/nothing works that way with
arrays, so I assumed it worked the same way with types. It seems like it
does not and uses a lower
Great :)