Giter Club home page Giter Club logo

Comments (5)

GDmac avatar GDmac commented on August 18, 2024

Also, when callbacks call methods inside other classes / objects, its hard to find the callee FSM-class to call getCurrentState(). Together with the above changes to setting the state late, why not also pass the states to the callback? Make those callbacks a bit more aware of the state the machine is in?

        $state = call_user_func_array($transition[1],
             array($symbol, &$this->_payload, $this->_currentState, $next_state));

from fsm.

thankgodness avatar thankgodness commented on August 18, 2024

I quite agree with you

from fsm.

jparise avatar jparise commented on August 18, 2024

Thanks for suggesting this improvement @GDmac!

I'm afraid I can't pass more information to the callback functions without breaking the current API, so I'm not going to act on your second suggestion at this time.

from fsm.

GDmac avatar GDmac commented on August 18, 2024

Yes, you totally can @jparise, the extra parameters are at the end, so applications that don't look at third and forth parameter just ignore it, and "newer" implementations can see if the arguments are present.

However, this suggestion is almost 3 years old (2012) :-) currently (2015) i'ld probably wouldn't want to clutter the parameter set and instead go with a single third argument, something like
array $parameterbag which can transport data and maybe even $this around.

from fsm.

jparise avatar jparise commented on August 18, 2024

You're right, @GDmac. I had forgotten that PHP handles function arguments that way.

I extended the callbacks to accept the full set of arguments (instead of moving to a single array payload) to maintain compatibility.

And yes, I was unfortunately preoccupied enough over the last three years such that I never sat down to work this out properly. :)

from fsm.

Related Issues (3)

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.