The current answer is because it would be unparseable.
Consider two-phase name lookup for templates, and in particular the need for typename. In templates, type-dependent names may not have been declared yet. To be able to parse them, we absolutely need typename
. Without that, parsing would grind to a halt and we can't reliably proceed, so we couldn't even provide the type needed to fix the parsing problem. It's a chicken and egg problem: If we need to have parsed line 10 to parse line 5, line 10 will never be parsed because we break at line 5. typename
helps us get past line 5 so we can learn the actual type on line 10.
Here, we'd have a similar problem. Consider this code under your assumptions:
struct Foo { };
int bar () { return Foo(); }
int Foo () { return 42; }
To parse this code, we need to know whether Foo
denotes a type or function.