[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CC-mode highlight change between 24.5 and 25

From: Davis Herring
Subject: Re: CC-mode highlight change between 24.5 and 25
Date: Fri, 2 Sep 2016 11:39:54 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2

I feared as much.  I've often wondered why the C++ language developers
have had such a low regard for unambiguous syntax, such as most other
(computer) languages have.  I've cursed them for it on more than one

Blame Ritchie (if we may speak ill of the dead), for similar vagueness dates to C:

/* Choose one: */
/* typedef int foo; */
/* void foo(int); */

int arg;

void f() {foo(arg);}

Depending on which of the declarations you include, "foo(arg)" is a declaration of a local variable "arg" or is a call to the function foo. (Obviously the declarations would typically be hidden in a header.)

Part of the reason for the introduction of uniform initialization in C++11 is to avoid the most-vexing-parse (though it does nothing for the above).

In other words, only semantics determine that the line 4 is a variable
declaration rather than a function declaration.  CC Mode doesn't do
semantics, except to a _very_ limited degree.  So we're reduced, yet
again, to difficult and unreliable heuristics.  Curse the C++ language

At least here the heuristic of "out of a function, it's a function; inside a function, it's a variable" works pretty well and both ways (since most people avoid global variables with constructors).


PS - If you like, I'll be sure to mention your curse in Issaquah (https://isocpp.org/std/meetings-and-participation/upcoming-meetings). (Just be sure to tell me on how many occasions you have cursed WG21; curses queue like POSIX real-time signals.)

This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]