News for hackers. Stuff that matters.
Re:A Deeply Skeptical Look at C++0x by scott_s on Thursday August 21, 2008 @02:10PM (#282954)

  for (std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i)
Versus,

  for (auto i = vec.begin(); i != vec.end(); ++i)
How is auto an astonishingly bad addition again?

Rvalue references solve a problem that library writers who are concerned with performance have. That most programmers don't need rvalue references misses the point - most programmers will probably depend on a library that benefits from rvalue references.

Re:A Deeply Skeptical Look at C++0x by huhtenberg on Thursday August 21, 2008 @02:45PM (#283001)
This certainly makes sense and it is useful. But that's not the use of auto i was referring to. This one is:

  auto func(int x) -> double;
I realize that the above is allowed primarily for this case:

  auto func(int x) -> decltype(x);
but from a casual examination the following - simpler and cleaner - notation can quite easily be made unambiguous:

  decltype(x) func(int x);
Also, isn't typeof a more natural name for decltype ? Again I realize that the keyword overlaps with existing gcc extension, but semantics of latter is a subset of C++0x one.
Re:A Deeply Skeptical Look at C++0x by scott_s on Thursday August 21, 2008 @06:02PM (#283211)
The reason

  decltype(x) func(int x);
Is not used is that it uses x before its defined. Hence the new function declaration syntax, where the return type is delayed until after the parameter list.

I actually agree that typeof is more natural, and I would prefer that keyword. But one of the committee's goals is to not have new language feature names clash with old conventions. Hence, the hashtable-based associative containers will be called unordered_, and not hash_.

Re:A Deeply Skeptical Look at C++0x by huhtenberg on Thursday August 21, 2008 @09:40PM (#283375)
> it uses x before its defined

Duh, noooo, really ? Have you ever wondered what magic causes this snippet to compile:

  struct foo
  {
    foo() { bar = 1; }
    int bar;
  };
In other words, C++ is perfectly capable of handling forward references. Parser can simply postpone evaluating decltype() expression until it reaches the end of the function declaration. That's hardly a compiler "rocket science".

I'm guessing that the real reason why they ended up with this ass-backward syntax was to try and achieve some consistency between these two cases:

  auto <variable>;
  auto <function>;
Was it worth it ? IMO - hell, no.
Re:A Deeply Skeptical Look at C++0x by scott_s on Friday August 22, 2008 @01:15AM (#283493)
Duh, noooo, really ?

This isn't slashdot. Please be civil.

Read Section 5 for the rationale provided by the committee members who proposed the syntax: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n170...

In particular, the name collision problem does not happen with classes because each class is a new scope.

Re:A Deeply Skeptical Look at C++0x by huhtenberg on Friday August 22, 2008 @04:01AM (#283541)
> This isn't slashdot. Please be civil.

Take it easy. You don't appear to have a good understanding of the compiler guts. What you said above was quite clueless, hence the reaction.

Also, slashdot as a metric of incivility - that's bold :)

> Read Section 5 for the rationale ..

I read the whole thing before I first posted in this thread. Since they are extending function declarations with a new construct, nothing precludes them from creating a scope for it. In other words, declspec() arguments should have a scope of a function declaration they appear in. Their claims that this also complicates parsing is just a speculation, and not too convincing one.

Re:A Deeply Skeptical Look at C++0x by scott_s on Friday August 22, 2008 @09:28AM (#283654)
I find it strange to say it's clueless when it's, in fact, the rationale used by the committee members. I don't appreciate being mocked when I'm trying to have a discussion. Compilers also happen to be part of my work, but that's beside the point.

Introducing a new scope would, I think, introduce more corner cases than the ugliness of the new syntax. (And I do agree that it's ugly in the context of C++ which already has a function syntax.) Right now, scopes are only introduced inside namespaces, classes/structs, functions, and explicit braces. Having a new scope start before a function and its parameters are declared is counter-intuitive to me.

Now, I might actually be willing to take counter-intuitive semantics to avoid the syntactic ugliness, but that's not my point. The point I've been trying to make is that the committee has considered these issues; they didn't blindly make a bunch of decrees.

Re:A Deeply Skeptical Look at C++0x by huhtenberg on Friday August 22, 2008 @10:14PM (#284410)
> when I'm trying to have a discussion

Your first response rebutted the point that I didn't make. Your second response was stating trivial stuff that was obvious to the point of not being even worth mentioning. So, yeah, I was also trying to have a discussion and go over finer points of the alternatives and why they used the least attractive one, but it didn't quite work.

> Right now, scopes are only introduced inside namespaces, classes/structs, functions, and explicit braces.

You forgot for loops. Their scoping is virtually identical to a function declaration scope if latter were to be used.

> The point I've been trying to make is that the committee has considered these issues; they didn't blindly make a bunch of decrees.

You have to realize that not all decisions made by the committee are based on a technical merit. There is quite a bit of politics and ego involved. Whatever they converge on might be a result that everyone is equally unhappy with rather than the opposite. Taking their decisions as written in stone makes very little sense .. unless, of course, they come directly from Bjarne :)

A well-known anecdote is a history of standardizing IPsec suite of protocols - a showcase for ego clashing. It took over two years to converge to something that the majority of a workgroup agreed with. It was a compromise on top of a compromise and the result was one of the most ambiguous and awkwardly written set of RFCs.