GC problems surfaced... there is a reason Julia can't have void references. How do I make a type-stable entity update system?

This should not be the first thing you try.

However, it is very hard to make useful suggestions since you didn’t explain in detail what you want to do. Please give some code that does what you want but is just too slow.

Some ideas:

  1. Dynamic dispatch: This solves the problem but allocates and is slow. But it is a very easy and straight-forward solution. So I suggest you type out an example of your problem using this.
  2. You have a single Entity type that contains the update function as field (use FunctionWrappers.jl for type stability). Now I don’t know where the data lives that this function operates on so I can’t comment on this.
  3. Use DynamicSumTypes.jl and essentially the same code as 1. DynamicSumTypes lets you pack all different types in a common supertype to ensure type-stability but you can still dispatch on the concrete type. I suggest you read the documentation. It is quite fast
4 Likes