Closed pleepleus closed 2 years ago
After looking more at the code, I think this is referring to the signature for ::new(), which does not take any arguments so thus there is no way to pass initial data for the state. I think a simple non-breaking change would be to change this signature to accept initial state data if the initial state holds data.
It looks like codegen.rs
actually generates a function signature new_with_state
, which theoretically allow the starting state to contain data. Have you tried this?
@ryan-summers, yes that works, and does provide a work-around if you just create a dummy start state with no data. But that's ugly. We can do better with the macro. We simply detect if the starting state has data, and we tailor the input signature of sm::new
so that if the starting state has data, it requires the initial data to be provided in the function.
I am just flagging this as an enhancement and assigning to myself. It will be easy to implement. I plan on working on this Friday.
Closed by PR #39
In the code, it says "because there is no way to propagate it (yet)". I don't fully understand this. Could someone more familiar with the reason explain?