Open mcoblenz opened 7 years ago
Can we discuss the pros and cons of this before committing to this? Maybe this is something to discuss with Jonathan/Josh/Brad. The advantage of constructors for the entire contract seem to be that they
1) document the starting state (or possible starting states), and 2) allow encapsulation, in the sense that the constructor can abstract away the details of how data is represented in the contract (i.e. "what fields are there?").
For state-specific constructors, I can see the latter use case being applicable in some cases, but I don't think there's as strong of an argument from the point of view of encapsulation, because states (by virtue of sharing at least the contract-wide fields) cannot be as encapsulated from each other to such a degree.
What is your thinking about this? Is there a particular example you have in mind where state-constructors are really helpful?
My argument is in terms of consistency and modularity. I see these benefits of state constructors:
We have contract constructors, so I think we should probably make the state transition syntax look more like invoking a constructor, and then support that properly (rather than ->S1({x = 3, y = 2}) ).