| New Reply |
Kicking the tires on C++0x |
Share Thread | Thread Tools |
| Apr14-11, 12:06 AM | #35 |
|
|
Kicking the tires on C++0xObviously it didn't appear to you that I was talking about for loops. I asked how didn't it appear so? What did I specifically say that made you rule out the possibility that I was talking about for loops and rule in the possibility that I was talking about auto? I'm baffled by this and I'm curious to see the train of logic... Code:
for (i = 0; i < whatever; ++i) {
printf("%i\n", i);
}
Code:
#include <stdio.h>
int main() {
int i;
int whatever = 4;
#include "include_me.idontcare"
}
There's no getting around how integral a part of C++ the preprocessor is so its use can't be shunned that badly. All you can do is ask that people write well behaved macros and good programmers try to do just that... |
| Apr14-11, 12:15 AM | #36 |
|
|
Is it worth it? The committee seems to think so. I guess I tend to agree although I suppose I'm somewhat conflicted on the issue... All I wanted to point out was that it's a little wrong... |
| Apr14-11, 12:31 AM | #37 |
|
|
Impossible is far from an exaggeration. http://en.wikipedia.org/wiki/G%C3%B6...teness_theorem You can either be complete or consistant. C++ chose to strive for completeness, apparently. |
| Apr14-11, 04:18 AM | #38 |
|
|
|
| Apr14-11, 04:25 AM | #39 |
|
|
Seriously, I find this an odd thing to get worked up over. I honestly don't understand how someone can find this important or even merely notable. Doubly so, given the slew of operator foo functions that various language constructs invoke. It's also not like begin and end came out of nowhere -- this usage had already been established in the standard libraries. |
| Apr14-11, 09:26 AM | #40 |
|
|
You obviously have to implement something to get your containers to work with range-based for loops but if you want these new loops, you do have to use certain identifier names, which is weird. Before, it didn't matter what aspect of the language you used, you never had to do this. This has changed... Your operator comparison makes no sense. That's like trying to compare what I'm saying to the fact that, in order to use while loops, you have to test a condition. Yes, you have to do certain things to do certain other things. It's hard to get around that. How is operator overloading the same as enforcing identifier names? |
| Apr14-11, 09:26 AM | #41 |
|
|
None of the new features you mentioned enforce identifier names on the programmer. Also, operator overloading is not the same thing as identifier enforcement... For example, I could do a search and replace for all instances of "begin" and "end" and replace them with "beginner" and "endorino" respectively and everything will work exactly the same because C++ never enforced identifier names on the user. Everything was user defined convention... Now, in C++0x, if you did this and your code used range-based for loops, it would curiously break. That's weird, no? |
| Apr14-11, 11:49 AM | #42 |
|
Mentor
|
I don't get your issue at all with current C++ not saying anything about the semantics of identifiers. It most certainly does! You raised two examples of where it does exactly that: constructors and destructors. The existing standard has quite a bit to say and semantics of constructors and destructors. |
| Apr14-11, 04:14 PM | #43 |
|
|
|
| Apr14-11, 04:19 PM | #44 |
|
|
|
| Apr14-11, 04:21 PM | #45 |
|
|
|
| Apr15-11, 01:10 AM | #46 |
|
|
I mean... "trolling..." really? I started by reminding us all that the include directive, which is necessary for library implementation, is a preprocessor function and has nothing to do with C++ syntax. Remember this? The include directive is a macro in the general sense and do behave similarly to C++ macros. I even gave a detailed example of what I meant. You deny my claim but you gave no specific argument other than that they use different keywords and declaring by fiat that they are "different beasts." Can you please be more specific than this? Hey, you never did explain how you concluded that I must have been referring to the auto keyword instead of for. You're pretty evasive... A number of languages don't have the values and priorities of C++. Languages that have range-based for loops, like Python or Ruby, are high level languages. They know nothing about the hardware they run on. C++, on the other hand, is a low level language. It's crazy how much C++ knows about the hardware. It's almost assembler language! ...not that that's the issue here. I just wanted to point out that different languages have different goals and values. Iterating over containers without the verbosity of C for loops (which is really what they are) is nice but how it was done is rather uncharacteristic of C++... C++ does force you to declare your constructor and destructor with the same name as your class but it did not dictate what the name of your class should be: only that they match. This is in stark contrast to range based for loops where you must declare your iterator functions to specifically "begin" and "end." That's it. Otherwise, they're not iterators. Not even "rbegin" and "rend" work... |
| Apr15-11, 01:48 AM | #47 |
|
|
Kidding aside, I'm not sure that BOOST_FOREACH is really any better but I do find it very interesting that such an implementation can be done without altering the language... I'm really not sure what they could have done if they wanted range-based for loops built into the language... which is probably why they tolerated this change but I'm sure there were some people on the committee who cringed as much as I did... Can you see why I still can't see the application? Okay, try answering this. If C++ was consistent before C++0x then, by your understanding, it wasn't "complete." Can you give an example of its lack of completeness? |
| Apr15-11, 02:04 AM | #48 |
|
|
"int" is a keyword. It has special meaning which is why you can't simply replace it with an identifier. "operator +" is an operator. It also has special meaning which is why you can't simply replace it with an identifier. If you use range-based for loops then "begin" and "end" also have special meaning... despite they not being keywords... Instead, they're identifiers that you may or may not use... except in range-based for loops where you'd better be using them! Now, BOOST_FOREACH also requires the existence of a "begin" and "end" method for non-built-in types but, because it's not part of the language, you can change this as a programmer if need be. In fact, it happens to be extensible! |
| Apr15-11, 03:29 AM | #49 |
|
|
Sorry, been busy for the last little bit and haven't had time to participate.
Jocko, I fail to see a problem in ranged for that warrants this level of discussion. Is it a nice feature that makes code clearer? Yes. Is it likely to cause problems/bugs in code? No. Is there a problem associated with adding support for it in your own lists? No. In short, no problem. It's a fine feature and I'm glad they added it. Wish this whole digression could be moved to it's own thread and not take up space in this one. Sorry, but it seems rather pointless to me. |
| Apr15-11, 03:17 PM | #50 |
|
|
|
| New Reply |
| Thread Tools | |
Similar Threads for: Kicking the tires on C++0x
|
||||
| Thread | Forum | Replies | ||
| Kicking a ball | Introductory Physics Homework | 1 | ||
| Kicking ball | Introductory Physics Homework | 4 | ||
| Kicking Below The Belt | General Discussion | 21 | ||
| Kicking the bucket | General Discussion | 23 | ||