Comment by canyp

4 days ago

I was about to complain about the use of strings in both libraries, both for the lack of type safety as well as the possible runtime allocation, but then I looked at the assembly for the sml example and there are no strings in the binary other than the obvious "send" one.

What exactly happened there? It looks like make_transition_table() is doing some serious magic. Or are the state transitions evaluated at compile-time given that there is no input in the example, and then the transition table gets compiled out?

Anyway, I think it would help OP's library to have some assembly output in the readme as well.

Looks like SML is using user-defined literals [0, 1] to effectively pre-process the string literal into state/event objects. Looks like the string itself is turned into a template parameter in the process and I believe those shouldn't show up in the compiled code (maybe unless there's some mangling-related thing going on?)

[0]: https://en.cppreference.com/w/cpp/language/user_literal.html

[1]: https://github.com/boost-ext/sml/blob/f232328b49adf708737bef...