Ah, I see! This saved me a lot of time tinkering. Thank you!
I need to handle defaults flexibly, and not require setting defaults on an struct that will encapsulate a lot of complexity. I think a Parameterized struct, with keyword arg out constructor solves these problems. Am I missing anything subtle here to be warned of:
struct Spacecraft{S<:AbstractState, T<:Time}
state::S
time::T
end
Hello Orestis, I was watching a few videos from last summer’s session at JuliaCon 2024 a few days ago. Do you know if a similar session is planned for 2025?
On the topic of units, for some purposes DynamicQuantities.jl may also be worth considering. The short version is that where Unitful puts all of the units in the type domain, so they are handled at compile time, DynamicQuantities (unless otherwise specified) puts everything into base SI marks and does any unit handling at runtime. The upside of this is that you can have a concretely-typed array of quantities with disparate units, which isn’t really possible for Unitful.
Both still have a little friction with SciML solvers, last I checked, but DynamicQuantities is a more natural fit I believe because of the array typing.
Another aspect of this topic I’m not seeing mentioned are packages like Accessors.jl which “make the immutable mutable”, or in other words provide easy ways to create a copy of an arbitrary (nested) struct with a particular value (or values) changed. I use this quite heavily, and if you need to take it a step further and programmatically change some subset of fields then setproperties from ConstructionsBase.jl will help.