Git Product home page Git Product logo

Comments (3)

SanderMertens avatar SanderMertens commented on June 18, 2024 2

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.

GsLogiMaker avatar GsLogiMaker commented on June 18, 2024

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.

copygirl avatar copygirl commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.