help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: .emacs poser


From: Yuri Khan
Subject: Re: .emacs poser
Date: Thu, 19 Dec 2013 08:13:43 +0700

On Thu, Dec 19, 2013 at 4:23 AM, Emanuel Berg <embe8573@student.uu.se> wrote:

>> Writing keywords in all caps used to be popular in
>> case-insensitive languages until syntax highlighting
>> editors became the norm. Nowadays, it’s not quite as
>> frequent.
>
> Is the preprocessor in C case-*in*sensitive? Because C
> isn't.

The preprocessor is case-sensitive, as is C. But, contrary to language
keywords, we the developers get to pick our macro names.

Because macro names are not namespaced and because they are known to
cause surprising effects when used carelessly, we pick them so that
they be highly visible and less likely to clash with other
identifiers. To the latter end, ALL CAPS provides a mini-namespace, if
we agree never to name non-macros in all caps.

>> If/when there comes a day when most editors (IDEs?)
>> can reliably detect preprocessor macros and highlight
>> them with a dangerous-looking shade of red, the
>> all-caps convention for #defines can also be dropped.
>
> This sounds like something that would be possible to do
> with Emacs today. As for the definitions, that would be
> a regular expression (very easy). But how to make it
> consistent in the rest of the buffer (i.e., where the
> constant is used), I don't know.

The highlight at definition time is not important; there we have the #
character to alert us that something shady is going on.

What’s important is the highlight at each use. Syntactically, macros
do not differ from ordinary identifiers, and their set is not constant
as in the case of language keywords. So the IDE must do some parsing
and remembering.

Also, macro definitions may be placed under conditional compilation.
So, depending on which branch is taken, different macros may be in
effect after definition. So the IDE must also understand conditional
compilation directives and be able to evaluate conditions.

Additionally, sometimes preprocessor macros are defined in the
compiler invocation command (-D switch for most compilers).


But sorry for off-topic; we are digressing here from the problem of
the rogue macron into the land of semantic parsers.



reply via email to

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