Re: New C++ 0x
John Nagle wrote:
This was suggested for C++ years ago, using the keyword "let". That
was considered to break existing code. Then it was proposed with the
keyword "auto", but that generated ambiguities.
The real reason for this was to allow
std::vector<int> tab;
...
for (let p = tab.begin(); p != tab.end(); p++)
{ }
instead of
std::vector<int> tab;
...
for (std::vector<int>::iterator p = tab.begin(); p != tab.end(); p++)
{ }
which is somewhat unwieldy.
Ofcourse the implicit type deduction would have been a smart and cool
feature. Here is what Bjarne says about in his article
http://www.artima.com/cppsource/cpp0x2.html
.....
"The difference from C++98 here is that we don't have to mention the
type of the iterator: auto means "deduce the type of the declared
variable from the initializer"
But the "can't add keywords" faction won, so it's a dead idea in C++.
From the above article it doesnt seem to be an abandoned idea.
The crux of the matter I want to point out is that, C++ programmers
community represent a very active and futuristic 'concept modeling'
one. But changes are always resisted in order to preserve existing
code base and other constraints. Bjarne says that we should only
introduce new features which would change the way people think.
We couldnt agree more. But if you take such a long time to implement
them, C++ would soon become much like C, unable to support the
paradigms of the times.
I am a paradigm follower rather than a language purist. Having
programmed in C++ for the past 8-10 years, it is obvious that I wouldnt
have been a C++ follower, if C++ lacked support for Generic programming
and other OO concepts of the times.And with the above set of features,
no amount of language evangelism would have saved me to stick to C.
I believe language evolution should keep pace with the paradigms of the
era. C++ has done an admirable job of doing just that knowingly or
unknowingly.
So, as we discuss about the new C++ 0x, let us examine the paradigms of
our times
and see whether they have been addressed in the language design.
In order not to make this too long , i briefly summarize what i think
1) Type Enhancements --> the abiliity to add to the utility of the type
in a partioned way.
For now, the friend operators add only to the static part of the type
and consider how useful it would be to enhance the set of instance
methods. A whole bunch of Library facilities would follow from this.
Libraries thrive on such features.
Reuse would get a new twist. Inheritance would become properly used .
As far as I know this is something that has not been addressed.
2)Type Awareness --> the ability of the system to "percieve" what a
type is, would go a long way in
a) monitoring
b) dynamic code injection
c) implemeting the data model more verbosely
d) enforcing contracts based design by building constraints.
the list goes on.
there is no point in providing this as a library (like in Reflection
API).This seems artficial.
"Concepts" in the new version is something in this direction.
Type awareness would also make the compiler errors more friendly.
3) First hand support for all Functional programming concepts(closures
and so on) thus freeing itself from its pure imperative mould. This
would enhance the domain of applicability of the language.Here opinions
would differ. It would be argued that a language cannot be everything.
But I see C++ 0x as a new language.
The list goes on.
Can we start(reopen) a discussion on how such lofty features could be
implemented in the C++ language.
......
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]