control-toolbox / CTBase.jl

Fundamentals of the control-toolbox ecosystem
http://control-toolbox.org/CTBase.jl/
MIT License
12 stars 3 forks source link

Use parametric type for model #306

Open ocots opened 1 month ago

ocots commented 1 month ago
          @ocots @jbcaillau Before that I forgot, you are using quite often a `foo::Union{Nothing, ...}` inside your structures for the type of the attributes. The compiler doesn't like that and it leads to additional allocations because it needs to check at runtime that it's a Nothing or not.

You can change that for foo::T and at the top of your structure T <: Union{Nothing, ...}.

Originally posted by @amontoison in https://github.com/control-toolbox/CTBase.jl/issues/271#issuecomment-2332691712

ocots commented 1 month ago

We could use the builder pattern according to @gdupont1.

gdalle commented 1 week ago

Just popping by to say that I can advise on this too if needed, following our conversation at the Julia & Optimization Days