3 ms·
Love Julia > Mutable struct fields may now be annotated as const to prevent changing them after construction, providing for greater clarity and optimization ab
by t6jvcereio 4y ago
Love Julia
> Mutable struct fields may now be annotated as const to prevent changing them after construction, providing for greater clarity and optimization ability of these objects
So will these be exactly like non-mutable structs?
- eigenspace 4y agoNo, it'd be a hybrid between a mutable and immutable struct. This allows you to control on a per-field basis whether the field is mutable or immutable.
- t6jvcereio 4y agoI get that, but my question is: if a type is mutable and I instantiate with const, will the exact same optimizations available?
- adgjlsfhk1 4y agothis isn't about instantiating a struct, this is about specifying that the field of a struct is const.
- t6jvcereio 4y agoOh fields. Got it.
- ChrisRackauckas 4y agoA mutable struct which labels all fields as const is an immutable struct. And yes it optimizes.