by jeffbee · 2y ago · 0 comments
auto value = std::to_underlying(p); // C++23
is "more expressive" than uint8_t value = static_cast<uint8_t>(Permissions::Read);
The latter seems clearly more expressive, not less. You could tighten it up a bit by using auto on the LHS instead of the redundant uint8_t. In the former I don't know what's going on and I have to go read another header to figure out the type of `value`.Matthias Felleisen
https://jgbm.github.io/eecs762f19/papers/felleisen.pdf
Abstract
The literature on programming languages contains an abundance of informal claims on the relative expressive power of programming languages, but there is no framework for formalizing such statements nor for deriving interesting consequences. As a first step in this direction, we develop a formal notion of expressiveness and investigate its properties. To validate the theory, we analyze some widely held beliefs about the expressive power of several extensions of functional languages. Based on these results, we believe that our system correctly captures many of the informal ideas on expressiveness, and that it constitutes a foundation for further research in this direction.
The expressiveness of an expression allows it to be used in more contexts, such as in generic code where the underlying type may not be known.