Comments (3)
The main reason for this functionality is that interfaces that can only use strings (like the JSON serializer, REST API, and as result the explorer) don't have to treat entities with/without names differently. Say you click on an entity in the explorer that doesn't have a name. To fetch the data for the inspector it'll send a request like this:
localhost:27750/entity/1234
You could differentiate between a name and an id by having something like:
localhost:27750/entity/1234
localhost:27750/entity_id/1234
But that would mean that the explorer (+ any other applications that use the REST API) has to be updated to explicitly handle entities with/without names separately. Since you can't enforce correctness across different clients, this would likely introduce a lot of new bugs where code doesn't correctly handle the two.
Another reason why this historically has been necessary is because 0
has been used to express DSL queries, like:
(ChildOf, 0) // get all root entities
I'm not opposed to changing this behavior (I've also ran into scenarios where I'd just like to use a number as a name), but I do not want to introduce a secondary entirely separate mechanism for uniquely identifying entities. Perhaps a middle ground is to for v4 do this:
1234 // entity with name 1234
#1234 // entity with id 1234
from flecs.
This would be a breaking change if applied to 3.x, but since 4.x is expected to have breaking changes, and is still in alpha, I hope that this change would make it in there.
from flecs.
At this time you can't completely separate the entity ID and name, because the DSL can parse not only entity names / symbols, but also numeric entity IDs. (This might come in handy when creating queries at runtime, though might be ugly using string expressions.) An alternative solution would be to assert when one attempts to supply a numeric ID to functions that set the entity name. A potential rule could be "entity names and symbols must not start with a digit".
Otherwise, I'd say I agree. When a function expects a name or symbol, it should not look up an entity by numeric ID. If that functionality is desired, perhaps it could be done through a separate function, like one that exposes the same method of lookup that the DSL parser uses? (If that doesn't already exist.)
from flecs.
Related Issues (20)
- Assignment within conditional expression error HOT 1
- When deleting an entity, the next created entity gets a bad ID (FLECS 3.2.9) HOT 1
- observer loss event HOT 2
- [Question] Best way to share a component between differents entities HOT 3
- README link is broken HOT 1
- Compilation failed with errors when declaring 'free' as a macro. HOT 1
- Explorer hierarchy incomplete HOT 6
- free(): invalid pointer when using sorted query with std::list HOT 1
- Bug or question - HOT 1
- Lockstep support, or deterministic calculations. HOT 7
- filter_builder() assert fail, when use term().or_() HOT 2
- Queries with Or terms and wildcard terms cause internal error HOT 1
- entity::set(T*) writes garbage HOT 1
- ECS crash after conditionally adding to an entity when using Explorer HOT 7
- flecs crashes at startup when using clang built from git
- I get exception errors in ms visual studio 2019 before the main function HOT 7
- Enabling or disabling a component between defer_suspend and defer_resume keeps the world deferred after progress
- World destruction with symmetric relationship and child causes assertion
- Add flecs.c and flecs.h as download artefacts for releases HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flecs.