#enums — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #enums, aggregated by home.social.
-
Magic Numbers sind Zahlen (oder auch Strings), die irgendwo im Code „einfach so“ stehen und deren Bedeutung man nur errät. Du siehst dann `60`, `3`, `1024` oder `"admin"` und musst aus dem Kontext heraus rekonstruieren, *warum genau dieser Wert* dort steht. Zahlen im Code sind nicht per se schl
https://magicmarcy.de/wenn-zahlen-luegen-magic-numbers-sauber-ersetzen
#MagicNumbers #Konstanten #Enums #Java #Programming #MagicStrings #Bedeutung #Dokumentation #Fachlichkeit
-
Magic Numbers sind Zahlen (oder auch Strings), die irgendwo im Code „einfach so“ stehen und deren Bedeutung man nur errät. Du siehst dann `60`, `3`, `1024` oder `"admin"` und musst aus dem Kontext heraus rekonstruieren, *warum genau dieser Wert* dort steht. Zahlen im Code sind nicht per se schl
https://magicmarcy.de/wenn-zahlen-luegen-magic-numbers-sauber-ersetzen
#MagicNumbers #Konstanten #Enums #Java #Programming #MagicStrings #Bedeutung #Dokumentation #Fachlichkeit
-
Magic Numbers sind Zahlen (oder auch Strings), die irgendwo im Code „einfach so“ stehen und deren Bedeutung man nur errät. Du siehst dann `60`, `3`, `1024` oder `"admin"` und musst aus dem Kontext heraus rekonstruieren, *warum genau dieser Wert* dort steht. Zahlen im Code sind nicht per se schl
https://magicmarcy.de/wenn-zahlen-luegen-magic-numbers-sauber-ersetzen
#MagicNumbers #Konstanten #Enums #Java #Programming #MagicStrings #Bedeutung #Dokumentation #Fachlichkeit
-
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.
-
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.
-
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.
-
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 -
I really, really like the django_enum package.
Imagine Django's TextChoices/IntegerChoices classes, but with the ability to encapsulate any additional information for each choice in one place.
I don't use it everywhere, but it's super useful in a number of use-cases.
Here are a few places where I've found django_enum makes things easier. See alt text for more detail about how I use of each of these.
Check it out: https://django-enum.readthedocs.io/en/stable/
And follow: @bckohan
-
Neat:
“A Surprising Enum Size Optimization In The Rust Compiler”, James Fennell (https://jpfennell.com/posts/enum-type-size/).
Via Lobsters: https://lobste.rs/s/w3jjb2/surprising_enum_size_optimization_rust
On HN: https://news.ycombinator.com/item?id=43616649
#Rust #PLDI #Compilers #Optimization #Enums #TaggedUnions #Variant #Efficiency #Programming
-
Neat:
“A Surprising Enum Size Optimization In The Rust Compiler”, James Fennell (https://jpfennell.com/posts/enum-type-size/).
Via Lobsters: https://lobste.rs/s/w3jjb2/surprising_enum_size_optimization_rust
On HN: https://news.ycombinator.com/item?id=43616649
#Rust #PLDI #Compilers #Optimization #Enums #TaggedUnions #Variant #Efficiency #Programming
-
Neat:
“A Surprising Enum Size Optimization In The Rust Compiler”, James Fennell (https://jpfennell.com/posts/enum-type-size/).
Via Lobsters: https://lobste.rs/s/w3jjb2/surprising_enum_size_optimization_rust
On HN: https://news.ycombinator.com/item?id=43616649
#Rust #PLDI #Compilers #Optimization #Enums #TaggedUnions #Variant #Efficiency #Programming
-
Neat:
“A Surprising Enum Size Optimization In The Rust Compiler”, James Fennell (https://jpfennell.com/posts/enum-type-size/).
Via Lobsters: https://lobste.rs/s/w3jjb2/surprising_enum_size_optimization_rust
On HN: https://news.ycombinator.com/item?id=43616649
#Rust #PLDI #Compilers #Optimization #Enums #TaggedUnions #Variant #Efficiency #Programming
-
Neat:
“A Surprising Enum Size Optimization In The Rust Compiler”, James Fennell (https://jpfennell.com/posts/enum-type-size/).
Via Lobsters: https://lobste.rs/s/w3jjb2/surprising_enum_size_optimization_rust
On HN: https://news.ycombinator.com/item?id=43616649
#Rust #PLDI #Compilers #Optimization #Enums #TaggedUnions #Variant #Efficiency #Programming
-
🚀 Wow, a whole article explaining that #enums in #Rust can be optimized! Who would’ve thought that a #compiler might actually, you know, do its job? 🙄 Next week: discovering that water is wet and that the sky is blue. 🌧️
https://jpfennell.com/posts/enum-type-size/ #Optimization #Insights #Programming #Humor #HackerNews #ngated -
Unleashing the Power of Flags in C# and ReactJS: Why This Simple Trick Changes Everything! (#csharp #dev #flags #dotnet #enums #reactjs #javascript #typescript)
https://raccoon.ninja/post/dev/unleashing-the-power-of-flags-in-csharp/ -
Desvendando o Poder das Flags em C# e ReactJS: Por Que Este Simples Truque Pode Mudar Tudo! (#csharp #dev #flags #dotnet #enums #reactjs #javascript #typescript)
https://raccoon.ninja/pt/post/dev/unleashing-the-power-of-flags-in-csharp/ -
🎉 TypeScript 5.8 swoops in with its shiny new flag, eager to send #Enums and #Namespaces to the retirement village of irrelevant coding features. 😜 Meanwhile, coders rejoice as Node.js finally catches up with the cool kids, #Deno and #Bun, for running TypeScript sans build step, as long as you're not too attached to those pesky old constructs. 🚫✨
https://blog.disintegrator.dev/posts/ode-to-typescript-enums/ #TypeScript5.8 #NodeJS #HackerNews #ngated -
Two Overlooked Uses of Enums in Java
-
Что выбрать для типов моделей: Enums VS Tables?
Enums VS Tables для создания типов моделей... Зачем использовать вообще одно из этих решений? Существуют модели, у которых необходимо выделить разновидности и сделать это именно с помощью типов, а не категорий... Разберёмся...
-
How to Use Enums in JavaScript
This JsDev article explains how to implement enums in JavaScript, despite the language lacking native support. It covers various approaches:
➡️ using objects and Object.freeze() for immutability
➡️ numeric enums
➡️ bidirectional enums
➡️ Symbols for unique values.It also touches on TypeScript's native enum support
-
Why do we have const enums in Typescript?
The article highlights how const enums are more efficient as they get inlined during transpilation, avoiding the extra code generation associated with regular enums. This can lead to smaller JavaScript files and faster build times. The author also provides examples and discusses the practical applications of both types of enums.
#TypeScript #Enums #ConstEnums #CodeOptimization #Programming
https://www.allthingstypescript.dev/p/why-do-we-have-const-enums-in-typescript
-
Why do we have const enums in Typescript?
The article highlights how const enums are more efficient as they get inlined during transpilation, avoiding the extra code generation associated with regular enums. This can lead to smaller JavaScript files and faster build times. The author also provides examples and discusses the practical applications of both types of enums.
#TypeScript #Enums #ConstEnums #CodeOptimization #Programming
https://www.allthingstypescript.dev/p/why-do-we-have-const-enums-in-typescript
-
Why do we have const enums in Typescript?
The article highlights how const enums are more efficient as they get inlined during transpilation, avoiding the extra code generation associated with regular enums. This can lead to smaller JavaScript files and faster build times. The author also provides examples and discusses the practical applications of both types of enums.
#TypeScript #Enums #ConstEnums #CodeOptimization #Programming
https://www.allthingstypescript.dev/p/why-do-we-have-const-enums-in-typescript
-
Why do we have const enums in Typescript?
The article highlights how const enums are more efficient as they get inlined during transpilation, avoiding the extra code generation associated with regular enums. This can lead to smaller JavaScript files and faster build times. The author also provides examples and discusses the practical applications of both types of enums.
#TypeScript #Enums #ConstEnums #CodeOptimization #Programming
https://www.allthingstypescript.dev/p/why-do-we-have-const-enums-in-typescript
-
Why do we have const enums in Typescript?
The article highlights how const enums are more efficient as they get inlined during transpilation, avoiding the extra code generation associated with regular enums. This can lead to smaller JavaScript files and faster build times. The author also provides examples and discusses the practical applications of both types of enums.
#TypeScript #Enums #ConstEnums #CodeOptimization #Programming
https://www.allthingstypescript.dev/p/why-do-we-have-const-enums-in-typescript
-
-
Harness the power of #Enums in Laravel with PHP 8.1's native enumerations. #Laravel v8.69 supports this, enhancing code cleanliness and efficiency. For a Post model with a 'status' attribute, define an Enum class, PostStatus, instead of using strings like 'draft', 'in_review', 'published'... Laravel's $casts property in the model converts these status values to Enums. Laravel also provides an Enum rule for form request validation. Embrace Enums for excellence and performance in Laravel projects.
-
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
-
You can't extend #PHP #enums, but you can have them implement an interface:
```PHP
<?php
interface TypeEnumInterface {}enum AType: string implements TypeEnumInterface
{
case A = 'A';
case B = 'B';
}enum BType: string implements TypeEnumInterface
{
case A = '1';
case B = '2';
}function tester(TypeEnumInterface $x) {
if ($x instanceof AType) {
echo 'Was AType: ' . $x->value;
}
if ($x instanceof BType) {
echo 'Was BType: ' . $x->value;
}
}tester(BType::A);
``` -
I created a #video demonstrating the code examples from an earlier #blog post: "Hidden Beauties of #Java #Enums".
Video: https://youtube.com/watch?v=U09ZQ3kjuqM
Blog post: https://webtechie.be/post/2023-03-22-hidden-beauties-of-java-enums/
Behind the scenes: still some work to do on my green screen as I'm not really happy with the final keying result. And you may hear some snoring in the background. That's our dog Wifi who was sleeping, really behind the scenes, as you can see in the picture ;-)
-
This is a really cool trick for #enums in #php .
https://laravel-news.com/extending-php-enums-with-attributes
-
Published a new #blog: "Let’s take a look at the power and beauty of what #Java #Enums can provide…" in which I explain how I use enums in various projects, even as some kind of "database" with the various @RaspberryPi boards.
https://webtechie.be/post/2023-03-22-hidden-beauties-of-java-enums/
-
@puppi Didn't read the paper, but it seems to me, that some #rust features would be simply impossible to implement this way, such as trait system, "fearless #concurrency" , Rust style #enums ... Basically everything, but borrow checker.
But it's an amazing idea anyways!
-
-
#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.
-