#enums — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #enums, aggregated by home.social.
-
For the gophers out there... Just a reminder: a bunch of consts + iota isn't an enum. Slugs aren’t enums. Interfaces, structs, and switch statements aren’t enums either.
Enums are enums.
Scala went through the same BS for what felt like a gazillion years.Just add a proper enum to the language. Go really needs a proper sum type. Don’t wait until Go v3 like we did in Scala.
"Simplicity" here is creating extraordinary levels of complexity.
-
Dear #lazyweb, what is the best way you know to represent #tagged #enums in #Python? It needs to be at least somewhat type-checkable, although it's possible I might settle for something like enumerating each value's associated data type/tuple once again for mypy to see.
So far I've been using a hierarchy of frozen dataclasses and then a single-dispatch handler; however, now I have a possible use case with the need for validation, and the hierarchy of dataclasses is not discoverable, thus not, well, enumerable :)
-
📚🤖 Ah, nothing says "cutting-edge innovation" quite like a 7-year-old article on #state #machines in Rust! Dive into this riveting tale of #enums and structures, where #computer scientists bravely pave the way to a "hopeful future" by rehashing #CS101 topics. Seriously, Samuel, enums again? 🙄🔄
https://hoverbear.org/blog/rust-state-machine-pattern/ #cuttingedgeinnovation #Rust #programming #science #HackerNews #ngated -
C programmers, please help me figure out something:
Since C23, a C enum may be declared to have a specific underlying type, as in the following example. My question is, how can I find the underlying type of such an enum? (C++11's std::underlying_type trait gets me this information.) 🙏
```C
enum Size : char { small, medium, large );
```Code example in C++ and C: https://sigcpp.godbolt.org/z/eo7Tdqaeb
C enum: https://en.cppreference.com/w/c/language/enum
#question #c #programming #cpp #cplusplus #enumerations #enums
-
#rust - #structs and #enums are the basis of what I'm trying to do I think, so....good direction! Unlike #ownership, this part actually makes sense for me.