How to work with arrays + objects

Given that there is no support for objects, and dynamically created arrays cannot be freed, what is the best way to work with an array of “objects”? The objects are constantly coming and going and changing in random order, but there is a maximum number of them.

Ideally I would use actual objects, and push them into and splice them out of an array. In this case, should I statically allocate a 2d array of the maximum size, and use one of the fields to mark the “object” as active or not?

Yes, something like that would work. I’ve created loosely coupled attributes that share an index. e.g. the sparks program.

I’ll probably add object support at some point, but I suspect there will be a performance tradeoff. Right now all access is direct, and calculated at compile-time vs run-time.

Aha. Yeah, the sparks pattern is pretty close to what I’m trying to make. I’ll use that as a reference.

1 Like

Awesome, and thanks for helping me test out this forum! I think I’ve finally found the setting to get properly notified when there’s new topics.