|
 |
Darren New <dne### [at] san rr com> wrote:
> But C++ syntax is so bad you
> can't even tell whether a line of code is a type declaration or a variable
> declaration or a function invocation without reading all the include files.
That's also one of the great assets of the language. Consider this:
template<typename F>
void foo()
{
F(5);
}
Is that F(5) a function call or is it instantiating a variable of type F?
It's impossible to tell without knowing what F might be.
However, it doesn't matter! As long as F behaves like a function, that's
just fine. This is used quite a lot in template coding, eg. with functors
and comparators. This gives flexibility and versatility.
It's not like C++ was the only language which behaves like this.
> To the point where you start getting things like the "typename" keyword
> (iirc) just to tell the compiler whether you meant to give a type or a
> variable name at that point.
Most languages have special keywords to denote what you want to do.
For example, some languages might have a keyword like "function" to denote
that you are starting a function definition, as opposed to starting a
function call. I don't really see the big difference.
> You can't tell me a language with undecidable syntax isn't at least a little
> sucky, yes?
When that syntax brings flexibility, I don't consider is such a huge
problem.
--
- Warp
Post a reply to this message
|
 |