|
I wasn't involved in the design, but it's probably because enum is a basic type: an integer on steroids if you like.
Which makes it a value type rather than reference, and those are implicitly sealed so they can't be inherited. That may be for performance reasons - inheritance checking each time you used a number could get seriously burdensome.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Surely, but so what? A new (better) language could be defined which does allow it.
There appear to have been a whole lot of bad decisions made in the design of .net -- the whole concept of, "this is a value type , this is a reference type", doesn't serve the developer. A whole bunch of classes are sealed or have non-virtual members for no good reason.
Far too much ivory-towering must gone on with too little defenestration of the culprits.
Very likely, they concentrated too much on attracting VB developers.
|
|
|
|
|
At least it wasn't four days!
|
|
|
|
|
There is that ... Always Look on the Bright Side of Life[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
David O'Neil wrote: Favorite 3 course video extravaganza: Life of Brian, The Meaning of Life, and The Blues Brothers.
I think I'd want to throw Blade Runner and Pulp Fiction in there? Maybe Chariots of Fire as well?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Loved Blade Runner! Hated 2049 - So boring!!!!!!!!!!!!!!!!!!!! Pulp Fiction - Great, but I think I'd go with his Kill Bill trilogy first - Fantasticer! (But they are both great!)
I'll have to check out Chariots of Fire - never seen it that I remember. Also need to watch Close Encounters, now that you fail to mention it.
|
|
|
|
|
I just spent a half hour tracking down a weird bug... I had left out an else ...
...
}
{
...
|
|
|
|
|
The compiler usually give you a warning about "Empty statement" (which in my case is usually intended and explained in a comment).
It shouldn't be much more difficult to give a warning: "Redundant braces". That would have caught errors like this.
Sure this comes in two levels: If there is no variable declarations or other scope-limited constructions within the block, the braces are truly redundant. With block local variables and the like, they may be intended even if the block is not associated with a control statement. I very rarely see code doing that; I think the number of "false positives" would be quite low. (And there could be an option to control it.)
|
|
|
|
|
Yeah, dunno, not a fan of warnings myself.
What would you expect for this?
# if EnableValidationOfX
if ( X > 0 )
# endif
{
... Do something potentially dangerous with X
}
|
|
|
|
|
For my preferred coding style, there would be no problem, as I put the opening brace at the line of the statement using the block, i.e. at the end of the if statement. That would be require the closing brace to be commented out as well - and the compiler would tell you, if you forgot to.
Assuming your bracing style with separate brace lines, you could of course do the same: Move the # endif down one line and add a # to the closing brace line. Whichever solution you choose, I dislike it: I assume that the block between the braces is indented. This is misleading when the 'if (X>0)' is not compiled.
However, I would never disable validation of X, and most certainly not by an #if directive. I would have made EnableValidationOfX a variable, so that it can be enabled without recompiling, in the binary environment where you experience a problem with invalid X values.
If you insist on the #if, and refuse to include the braces in the conditional compilation, I would prefer that the compiler gives a warning if you compile with EnableValidationOfX is false. If this coding style is common to you, you should probably disable the "Redundant braces" warning altogether.
There is another construct where I guess that lots of others disagree: In a switch(), I like to indent the statements in each case from the case label. I also frown when I see an indent/undent with no brace: Braces and indents go hand in hand. So I like to add braces around the lines of each case. But C class languages do not require case to be a block (also, a single statement is not defined to be a block), so the braces are redundant. If we got the compiler to warn about redundant braces, I would want it to have options to allow my coding style of making each case alternative a block. (But I guess a lot of you would scream at my use of redundant braces in switch() statements!)
One thing I like about lint is that you can insert a lint comment that disables a check for this line only. If you occasionally, but not very often, use constructs like the one above, a similar mechanism for suppressing the warning at this occasion as a special case, would be very nice. It would also serve as a documentation to other programmers to explain that the braces are indeed intended.
|
|
|
|
|
trønderen wrote: each case from the case label.
trønderen wrote: Braces and indents go hand in hand
Uh, huh, I agree...
switch ( foo )
{
case bar :
{
...
break ;
}
...
}
|
|
|
|
|
The suits just said ship it anyway.
>64
Some days the dragon wins. Suck it up.
|
|
|
|
|
I honestly don't understand the point of this post. Is it a joke?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
No, it is not a joke.
My code was return(index--) and whyever in my brain it was equivalent with return(index - 1)
|
|
|
|
|
If you want index-1, you can use this
return (--index);
The way you did it, index was decremented after the return (a "postfix decrement"). You want it to be decremented before it's returned (a "prefix decrement .
Prefix Increment and Decrement Operators | Microsoft Docs[^]
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Unbelievable!
That should be ‘calculateIndex’!
If you can't laugh at yourself - ask me and I will do it for you.
|
|
|
|
|
I can't say I've ever written a bug as that one however I've written a few zonkers which I often find by accident examining the code for other reasons. I consider myself fortunate to have found the bugs in such situations. Perhaps I was born under a lucky star.
|
|
|
|
|
I am considering switching from Windows10 to Windows11.
If you have already done that, please let me know:
Is it better enough than 10 to make the switch worthwhile?
Is it stable enough at this point?
Do you have any suggestions on the best way to make the switch?
Did you lose any of your data, programs, etc. when making the switch?
Are you happy that you did?
Any thoughts, suggestions would help.
Ed
|
|
|
|
|
I've not heard any horror stories (but I've not actively been listening for them)
The safest way to switch is to reformat and install from scratch.
Upgrading from a current OS usually work, I remember a long time ago that it created some instabilities, but that was a long time ago.
Also, before you do upgrade, make backups of all sensitive things.
Unfortunately, my hardware does not support Windows 11, I know I could probably order the TPM chip, but I intend to upgrade my hardware in the next few months anyway.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
The initial version of 11 had some issues that caused me to dump it. (Some of my apps, like Intellij Idea, refused to even start up on the first 11 version. I had to revert to 10 and waited for a more stable version of 11.
However, MS quickly fixed the isue and after installing the latest version of 11 I am totally happy! Regarding losing some data or apps: Not applicable in my case since I did a clean install of 11, which means I had to re-install everything. It took me the better part of a morning to do.
Note: I have a separate internal drive for my data, so that does not get lost in a clean install. I keep the C: drive just for the operating system and applications. This makes a clean install a lot easier. It also means that I can make a Macrium image of the C: drive that will not be bloated up by gigabytes of data.
Get me coffee and no one gets hurt!
|
|
|
|
|
Cp-Coder wrote: Note: I have a separate internal drive for my data, so that does not get lost in a clean install. I keep the C: drive just for the operating system and applications. This makes a clean install a lot easier. It also means that I can make a Macrium image of the C: drive that will not be bloated up by gigabytes of data. +1 on that procedure
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I did the upgrade from 10 to 11 as opposed to a clean install.
I lost no data.
The upgrade went smoothly.
So far the system has been very stable.
I've been able to do everything on 11 that I could do on 10.
I don't see a huge difference in systems, but there are things that are better.
Would I recommend? YES
The most expensive tool is a cheap tool. Gareth Branwyn
JaxCoder.com
|
|
|
|
|
I had same experience as Mike. You also need to make sure you are using the latest video card drivers. I am using 64 bit version. No reinstall needed for my applications.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
1) Erm ... from a user perspective no - the changes are mostly cosmetic and actually degrade the UI functionality in some cases, particularly the taskbar (You can't move it from the bottom of you main monitor and it takes up more space)
2) Yes. It seems solid.
3) I'd recommend a clear-and-reinstall, but I'm still running on the upgrade version because it wouldn't do a clean install when I switched. Doesn't seem to have caused any problems (But I suspect there are still bits of Wn 7 in there somewhere, because I think that was the last OS I clean installed).
4) No.
5) Yes and no. It's working ok, but I'd still like some of the old functionality back, and it takes longer to do some things: right click in Windows Explorer brings up a "UWP" menu - spaced out, bigger font, and truncated in what you can do. To rename a file, you right click for that menu, then select "Show more options" and a new old-style menu pops up with smaller font, and tighter spacing which includes the "Rename" option.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|