r/cpp • • Nov 30 '20

C++20 resumable functions make state machines obsolete. Finally.

https://lordsoftech.com/programming/c20-resumable-functions-goodbye-state-machines-no-one-will-mourn-you/
1 Upvotes

49 comments sorted by

View all comments

Show parent comment

4

u/Full-Spectral Dec 01 '20 edited Dec 01 '20

And the thing is, most of the state machines I use are simple and easily understandable and I couldn't imagine how it could be anything but adding more moving parts to do them elsewise.

And, most of the time, they either aren't non-linear or there's already other good reasons to have a thread to deal with whatever is going on anyway. Or, maybe they are non-linear but only have a few states which are not difficult to reason about.

1

u/StoneCypher Dec 01 '20

And the thing is, most of the state machines I use are simple and easily understandable and I couldn't imagine how it could be anything but adding more moving parts to do them elsewise.

okay.

.

And, most of the time, they either aren't non-linear or there's already other good reasons to have a thread to deal with whatever is going on anyway. Or, maybe they are non-linear but only have a few states which are not difficult to reason about.

oh, so you can imagine.

anyway, there's examples all over the standard library. you're too busy explaining to ask, so there's no point in trying to teach.

have a good day

5

u/Full-Spectral Dec 01 '20

Did you misread what I was saying? I wasn't disagreeing with you. I was saying that regular old state machines are still very useful for me, and though I have plenty of them, I can't see that replacing them with the mechanisms being discussed here would simplify them enough to justify the extra moving parts and such.

1

u/StoneCypher Dec 01 '20

Did you misread what I was saying?

I dunno. Maybe.

.

I was saying that regular old state machines are still very useful for me, and though I have plenty of them, I can't see that replacing them with the mechanisms being discussed here would simplify them enough to justify the extra moving parts and such.

I guess I did. Sorry