ecs: type-safe queries/iteration #402
No reviewers
Labels
No labels
CI
all
basisu
blog
bug
build
contributor-friendly
core
correctness
deferred
dev
direct3d-headers
docs
driver-os-issue
duplicate
dxcompiler
editor
examples
experiment
feature-idea
feedback
flac
freetype
gamemode
gkurve
glfw
gpu
gpu-dawn
harfbuzz
help welcome
in-progress
infrastructure
invalid
libmach
linux-audio-headers
long-term
mach
mach.gfx
mach.math
mach.physics
mach.testing
model3d
needs-triage
object
opengl-headers
opus
os/linux
os/macos
os/wasm
os/windows
package-manager
priority
proposal
proposal-accepted
question
roadmap
slipped
stability
sysaudio
sysgpu
sysjs
validating-fix
vulkan-zig-generated
wayland-headers
website
wontfix
wrench
www
x11-headers
xcode-frameworks
zig-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
hexops/mach!402
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "typed-query"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Now that we have typed ecs components, it makes sense to get type safety into the query/iteration api. This is a first past that works, but I'm not thrilled with the api (passing the query to the
next()function rather than thequery()function that constructs theIterator. To make the components a comptime parameter toquery()instead ofnext()requires the information about the query to be stored in the iterator, which would meanIteratorhas to be generic over the components queried. Alternatively the component query could be runtime information, but that would require allocating (to concatenate namespace and component name), or imposed a maximum length for namespace + component name.How should the api for type-safe queries and iteration look? In the future when multithreading/scheduling is worked on this will probably need revisiting as knowledge of what kinds of queries/iteration is done can be exploited for scheduling, but in the meantime it would be good to have a type-safe way to iterate.
Thanks for this. I've yet to get around to looking at querying in depth yet, realistically I think that querying cannot be looked at in isolation. Here's what I mean:
These four items must be considered together, because each one impacts the other. So far I've gotten close to completing the first two, and investigating the third, but not yet all of them together.
I'm happy to merge this PR as-is right now, though, because it's a clear improvement over what we have today. Any objection to that?
I've pushed a second commit that fixes API so that you pass the components you want to query to the
query()function rather thannext(), by making theIteratortype generic over those components.The reason I made this PR a draft was essentially because of those other parts of Mach that querying needs to interact with and wasn't sure how much thought others have put into the API. I'm happy to have these changes merged - these changes can be a starting point for developing the API as those other aspects are considered/implemented (I guess it would be very hard to get all of it 'right' in one go anyway).
I'm not certain what you mean with queries and Modules (and message passing) impacting each other (unless all you mean is that the comptime known components must match up).
Yup, that's exactly what I mean :)
Some examples:
All this to say, there's a lot of conflicting concerns to address - and as you mentioned they can't all be addressed at once. But it's important to address all of them before we say the API is stabilized at all.