- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
int a = 123; int b = a + 1234; int c = b - 1234;
// hooray, we did it! c is now equal to a!!
Admin
And Python actually has an
Enum
class.Admin
Which is stated in the article.
Admin
That's called "I learned this but don't know how to use it" and is not a WTF. TRWTF is never going back to learn how to use it.
Admin
Or possibly some poor guy started down the Correct Path of using an enum//define, but both misunderstood how it should work and never got back to it.
Admin
The
Enum
class has been there for quite a few years. It was even backported to 2.7 (I used to have code that used it.)More horrible was the
IntEnum
for people who insist on making their enumeration values support arithmetic operations.Admin
Please for the love of cthulhu will you stop using WHICH as a conjunction? It boggles the mind that a website devoted to encouraging better code through pointing out tiny deviations from sensible and readable style can't get its own English better written.
Admin
Depending on what's in the rest of the code, it may be useful. After the assignment, 'operation' is guaranteed to have one of the valid values. This means later uses can safely use it to construct strings which otherwise would be vulnerable to injection attacks.
Admin
Are you talking about the sentences that begin with "Which"? What's wrong with that?
However, I think "Strings which have" should probably be "Strings that have".
Admin
"This Python class essentially emulates an enumeration, which while enumerations are now available in Python, it's perfectly plausible that this code predates it and it's fine." That one is acting as a conjunction; "and" would make more sense, perhaps "but", depending on the intended tone. "Which" makes no sense in that sentence. An enumeration, which IS... what? which DOES... what? which something else acts upon in some way? Even "which is now an available feature of Python" makes sense. Here it's just a train of thought that runs out of track.
Admin
Meanwhile me, wishing that Fortran had a proper typesafe enum concept.
Though it can be emulated easily with a user-defined type with one value, named integers abound :( Heck, just using string constants would be better, but somehow Fortran programmers seem to think that string comparisons are expensive. Sure
Is faster than
but unlikely to actually make a difference...
Admin
Look best college essay writing service www.essayshark.com here in link. This service provide best help in writing essay in the USA.
Admin
If they are Fortran programmers, they would think that
Is faster than
and they would be right unless
c_type
andTYPE_A
are small enough to fit into a singleINTEGER
value.Admin
As I said -- it is faster. It just doesn't actually make a difference. These type comparisons are very rarely an "inner loop" situation. And even then you could easily emulate type-safe enums with something like
and get barely a performance penalty for doing
For most cases though, using some
CHARACTER(LEN=8)
will not make a relevant performance difference to using an integer, be more useful when debugging, and help to catch at least some bugs (e.g. passing arguments in the wrong order).Addendum 2023-02-28 04:30: I missed the change for making an
et_al
"typo".Admin
Caiganle encima a esa puta.
Admin
Judging by google translate, that comment should probably be removed.
Admin
A pagina de login do 1win Casino (https://1win-slots.com/pt/1win-cassino-login/) e a porta de entrada para uma experiencia de jogo emocionante e repleta de diversao. Ao acessar a pagina de login, os jogadores podem criar uma conta e ter acesso a uma ampla variedade de jogos de cassino, incluindo slots, jogos de mesa e muito mais.
Admin
Hi) Maybe you are still in university and you have an essay assignment) And if you want to get help with writing texts, then I offer you this essay writing service! It's the guys from https://www.wiseessays.com, they have never let me down yet)