The obvious thing I should've learned 5 years ago
The obvious thing I should've learned 5 years ago
So I'm a self-taught C programmer. Well, after about a year or two of C programming/OS hacking, I taught myself just about everything. Structs, enums, function pointers, etc etc.. (I learned unions about 3 or 4 years after starting C btw cause I see very little use for them)
Well, I was just skimming through my book for C++(I already know about everything in the book except for where it barely touches on templates) for a class and in chapter 3 (read: chapter that is taught 4 weeks into the class) and I discovered this keyword. `continue` I looked and realized I'd seen it some places but actually had no idea what it was.
How could I have actually not known about this amazing keyword!? Been programming C for over 5 years now and I'm just NOW figuring out that there is a `continue` keyword!? When I learned Ruby, I thought C was extremely lacking because of it's lack of a `next` keyword... Well, la de da it was right there...
Hopefully, the continue keyword isn't news to you, but share your similar experiences. What is missing in your knowledge that is so basic that you should've learned it after a week of beginning programming?
Well, I was just skimming through my book for C++(I already know about everything in the book except for where it barely touches on templates) for a class and in chapter 3 (read: chapter that is taught 4 weeks into the class) and I discovered this keyword. `continue` I looked and realized I'd seen it some places but actually had no idea what it was.
How could I have actually not known about this amazing keyword!? Been programming C for over 5 years now and I'm just NOW figuring out that there is a `continue` keyword!? When I learned Ruby, I thought C was extremely lacking because of it's lack of a `next` keyword... Well, la de da it was right there...
Hopefully, the continue keyword isn't news to you, but share your similar experiences. What is missing in your knowledge that is so basic that you should've learned it after a week of beginning programming?
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: The obvious thing I should've learned 5 years ago
The continue keyword should be one of the fundamentals you learn when you learn loops... or so I thought?
I guess you wouldn't know what the restrict keyword is for, then?
I guess you wouldn't know what the restrict keyword is for, then?
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: The obvious thing I should've learned 5 years ago
With C/C++, there's still a lot I have yet to learn (like where to put const for different situations, or memorizing template syntax), but continue is something I've known since pretty close to the beginning. I do admit, though, that I've forgotten about it once or twice, since I don't often need it.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: The obvious thing I should've learned 5 years ago
Just looked up what restrict is.. Pretty hardcore.. lolpcmattman wrote:The continue keyword should be one of the fundamentals you learn when you learn loops... or so I thought?
I guess you wouldn't know what the restrict keyword is for, then?
And yea, I also don't have the whole const/volatile order memorized for pointers..
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: The obvious thing I should've learned 5 years ago
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: The obvious thing I should've learned 5 years ago
Wow, That's so much more subtle than while loops in while loops.
Modular Interface Kernel With a lot of bugs
Re: The obvious thing I should've learned 5 years ago
I've heard about pretty much all the standard C/C++ keywords before but pretty much never used all of them. For example, I've never had any use for the mutable keyword, which states that a member of a class can still be modified, even if the object of the class is defined as const (or at least that's what I thought it was).pcmattman wrote:The continue keyword should be one of the fundamentals you learn when you learn loops... or so I thought?
I guess you wouldn't know what the restrict keyword is for, then?
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Re: The obvious thing I should've learned 5 years ago
So your code was full of gotos to replace continue?earlz wrote:How could I have actually not known about this amazing keyword!? Been programming C for over 5 years now and I'm just NOW figuring out that there is a `continue` keyword!?
Not nearly as basic, but I didn't know about C99 compound literals for a long time.
Re: The obvious thing I should've learned 5 years ago
It IS... news to me Never made it past chapter 3 of C++ forHopefully, the continue keyword isn't news to you,
dummies before I went back to ASM.
My hero, is Mel.
Re: The obvious thing I should've learned 5 years ago
I never knew that C++ templates are Turing-complete until a coworker told me that.
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Re: The obvious thing I should've learned 5 years ago
Only in theory... Most compilers have pretty hard limits on the depth of template recursion they support.Grunt wrote:I never knew that C++ templates are Turing-complete until a coworker told me that.
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
Re: The obvious thing I should've learned 5 years ago
No, it was more likeKevin wrote:So your code was full of gotos to replace continue?earlz wrote:How could I have actually not known about this amazing keyword!? Been programming C for over 5 years now and I'm just NOW figuring out that there is a `continue` keyword!?
Not nearly as basic, but I didn't know about C99 compound literals for a long time.
Code: Select all
while(..){
if(....){
//we need to go to the next iteration.
skip=1;
}
if(!skip){
//regular code...
}
}
Re: The obvious thing I should've learned 5 years ago
I've been programming C for less than a year, and I know it :learlz wrote:pcmattman wrote:And yea, I also don't have the whole const/volatile order memorized for pointers..
If the const is before the data type, as in
Code: Select all
const char* s = NULL;
Code: Select all
const char
If the const is after the data type (and asterisk), as in
Code: Select all
char* const s = NULL;
Code: Select all
char
So in the first case, you can re-point s, but you can't modify what s points to (unless you use another pointer, like
Code: Select all
char* hax = s
What I want to know is what happens if I do this:
Code: Select all
const char* const s = NULL;
I didn't know restrict though, thanks for that
Re: The obvious thing I should've learned 5 years ago
I think the reason most people don't know about restrict is that it wasn't (still isn't?) included in the C++ standard...