Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mechanism for marking states as explicitly terminal #61

Open
durin42 opened this issue May 16, 2017 · 3 comments
Open

Mechanism for marking states as explicitly terminal #61

durin42 opened this issue May 16, 2017 · 3 comments

Comments

@durin42
Copy link

durin42 commented May 16, 2017

Today you can do machine.state(initial=True) to mark the initial state of a machine. In tinkering with automat today, I've got a machine that has some explicit end states, and it occurred to me that it'd be nice to be able to mark them as machine.state(terminal=True) and then if you try to do .upon(some_action, ...) on them, they'd explode with an error about trying to leave a terminal state.

@glyph
Copy link
Owner

glyph commented May 17, 2017

This is a somewhat intentional design choice, although I'd definitely be OK with revisiting it.

The idea is: initial=True is necessary so that we can know what state that the machine begins in. However, the only thing that makes a terminal state "terminal" is that there are no edges that exit from it.

What is the motivation for wanting to prevent calls to .upon?

@durin42
Copy link
Author

durin42 commented May 17, 2017

Mostly preventing errors where I know I can be explicit. I'm working on an API where users will be interested mostly in the final states. I'll try and figure out how to explain this desire more clearly. It just feels weirdly asymmetric that initial states are declared but you can't declare terminal states explicitly even if you want to, it just has to be implicit from the available transitions.

@glyph
Copy link
Owner

glyph commented May 17, 2017

There are some other inherent asymmetries though - for example, you can only have 1 initial state per machine but N terminal states.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants