- 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
he must be knew to the internets
Admin
Seems to me back when I was learning Pascal, booleans were defined as a specific instance of enum.
Admin
Admin
Admin
Consequently, it will not let you use enums as flags at low level libraries. Guess the place where enums are mostly popular in C.
Admin
Yep. I/O is dangerous stuff. Keep it out of the way of newbies.
That said, the only ironic thing up there is the "keep it out of the way..." part. The rest is just true.
Admin
Admin
It's the one with superior set handling, dummy.
Admin
Admin
flannel!
Admin
why would anyone want to use a set of enums anyway? That's just craazy talk...
Admin
Admin
Agreed, 1.5 stop bits is important, at least historically.
The WTF I was talking about is that you fill in a DCB with a number of data bits, a number of stop bits, etc. The code for data bits is 7 for 7 bits, 8 for 8 bits. But the code for 1 stop bit (which is 99% of the cases) is
#define ONESTOPBIT 0
Admin
Admin
I think it's Mr Bunny's Big Cup o' Java that demonstrates the simplest Java program is just whitespace.
Admin
I have a suspicion [strikeout]Microsoft Java[/strikeout] C# is much the same. And I thought we'd had arguments about it already, with the general consensus as the OP: If you want a class, make a class.
Admin
Reminds me of the time one of my colleagues defined a not-very-good enum. It made maintenance difficult till it was fixed.
Admin
Admin
Admin
Admin
Admin
Admin
If you want X, make X.
I'm tired of people inventing Y to solve/replace/complement X, simply because they don't understand X.
Admin
Good thing he finished with that bit about constants though, amirite?
Admin
One question, and I'm surprised nobody asked yet, but I (for one) am interested to know:
Admin
Admin
Hey! It's sending a 16 TB file at 9,600 baud; uncompressed; with 1.5 stop bits. It'll finish sometime around 2560.
(Ah, how spoiled we are and don't know it.)
Admin
Admin
True, in C# you can actually compile this:
which actually will raise an exception at runtime, although you thought that using TryParse would protect you against them.
Even uglier is that
method for which even backwards compatibility is not a good excuse to still exist.Admin
Admin
Of course, the problem with powerful features is that they can easily be abused, and I could imagine the case where someone writes a database connection pool in an enum. Why? Why not?
What I like about Java over C# is that Sun/Oracle/JCP are a bit more careful with adding new features. It took them a while to add enums, but the chosen solution is quite elegant, contrary to how they did generics.
Although Java 7 is long overdue; in fact, it's gone stone cold in terms of coffee.
Admin
Java 7 was released last Thursday - although I understand that Apache may have found some bugs in it.
Admin
Admin
Java coders found a way around this on about day 2.
Result of Java nannying: It has the same amount of trash as languages with enums, it's just more verbose and harder to read.
Admin
Enums in the global namespace = bad idea.
Scoped enums together with strong type checking = good idea.
Admin
raises an eyebrow
Admin
Polymorphic perversion.
Admin
FTFY
Admin
Your syntax is too far off, that array is completely unneeded.
Admin
Language Abuse
Admin
-Harrow.
Admin
fuk JAVA
Admin
'John continues, "I didn't even realize that _1 was a valid identifier..."'
John undoubtedly also does not know that '' is a valid identifier. (Or '', '', etc.)
I often include this constant definition:
_=0;
which I then use to mark unused constant array entries, to distinguish them from required entries equal to zero.
When anybody questions this practice I explain that a singulized underscore is a perfectly cromulent symbol.
-Harrow.
Admin
It's the perpetuation of this stereotype that frustrates me to no end playing poker with new players.
I'll see your x and raise you y!
No, you said I'll see your x. End of bet. You can't raise after that, it's a string bet that you're making with your mouth.
Admin
The OP first states that fixing bugs is a high priority for him. Then, being a sensible developer, he finds that replacing an identifier that he did not know was syntactivally valid (due to his unfamiliarity with the language he's using) is even a higher priority than fixing bugs. That does not fit well with my definition of "sensible," sorry. To me, the WTF is with his assessment of priorities, not with the code.
Admin
Very easy to abuse white space:
Admin
This is what we do in OCaml: _ stands for any formal argument (or, generally, part of a structured value pattern) that you do not want to refer to and, hence, do not want to bind to a name.
Admin
Admin
The enums in the OP specify versions. You can just see them being passed to methods to specify which version of behavior you want the method to follow. This is handled better by polymorphism, wherein behavior is specified by type rather than parameter.
Of course, at some point you have to decide which subtype to construct. Hopefully, these enums are only being used in a switch block with constructor calls in them and nowhere else. But I have my doubts.
Admin
So what exactly is the correct terminology for matching the amount of money being put into the centre of the table, then adding a little bit more, with the intention that it go round the table once more?