Comments (5)
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.
I quite agree with you
from fsm.
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.
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.
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
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 fsm.