Open gafter opened 1 year ago
(The disadvantage is that every field access has to go to the heap. With an immutable struct, fields can be pulled onto the stack or into registers, which can improve the performance of a function that spends a lot of time with those fields. If you're just hopping off to the next child in a tree or something, this probably matters less.)
Either
const
, orconst
to each declared field (with a warning?) if not already declared so.The advantage of doing this is that we get both an efficient hash code and an efficient equality (because of the
===
shortcut)const
on a field is only available in Julia 1.8 and later.