3 ms·
Let's imagine we want to program some kind of state machine machinery. We can ask ourselves questions: what should it do? how should it work? what kind of feat
by lispm 2y ago
Let's imagine we want to program some kind of state machine machinery.
We can ask ourselves questions: what should it do? how should it work? what kind of features would it need to provide? From what parts would we like to build it? How can we integrate it into the programming language we use? How can we make it fast? How can we deal with errors?
There is a question we haven't been asking yet: how do we want to write them down? What would be a compact notation, verifiable for a state machine?
That's something which one can ask very early in Lisp: How should my code look like? How can I make sure I understand the state machine itself (not the low-level programming) months, years later and make changes to it?
One way to answer that would be to add a syntax extension for state machines to Lisp. That would be embedded into the language. One can experiment with that, without the need to write too complex scanner&parser combinations. Just write the state machine as a list of state descriptions. A macro could transform it at compile-time into (efficient) low-level operations.