Giter Site home page Giter Site logo

Comments (3)

eao197 avatar eao197 commented on May 21, 2024 1

Good question! :)

I think it's some heritage from ancient times. I don't think there are some reasons that prevent making agent_t::st_default non-const member of agent_t. I'll try to look deeper tomorrow (or Monday) and if there is no any other issues I'll change the st_default and add a new overload for so_default_state.

from sobjectizer.

eao197 avatar eao197 commented on May 21, 2024

There is a hidden underwater rock: a call to on_enter handlers for child states. For example:

class demo final : public so_5::agent_t {
   state_t st_parent{this, "parent"};
   state_t st_child_1{initial_substate_of{st_parent}, "child_1"};
   state_t st_child_2{substate_of{st_parent}, "child_2"};
   ...
   void so_define_agent() override {
      st_child.on_enter([]{ std::cout << "Hello, World!" << std::endl; });
      ...
      this >>= st_parent;
   }
};

In that case "Hello, World" would be printed at the start of demo agent.

But in that case:

class demo final : public so_5::agent_t {
   state_t st_child_1{initial_substate_of{so_default_state()}, "child_1"};
   state_t st_child_2{substate_of{so_default_state()}, "child_2"};
   ...
   void so_define_agent() override {
      st_child.on_enter([]{ std::cout << "Hello, World!" << std::endl; });
      ...
   }
};

The enter handler for st_child won't be called at the start of demo agent. It's because st_default is already the current state for the agent and SObjectizer doesn't know about changes that should be taken into the account.

from sobjectizer.

zamazan4ik avatar zamazan4ik commented on May 21, 2024

Hm... interesting case. In my opinion that's just "nice to know" thing, which shall be documented, if you want to allow so_default_state as a parent state in SObjectizer. In my case the example above doesn't matter at all.

For now locally I just created my own default state :)

from sobjectizer.

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.