jack: (Default)
[personal profile] jack
How much syntax highlighting do you generally get when you edit code? Any?

Does it call out different variable types?

Can you easily configure it dynamically to eg. highlight different ifdef branches or variables with certain prefixes?

Should it be able to?

Date: 2007-04-25 01:17 pm (UTC)
simont: A picture of me in 2016 (Default)
From: [personal profile] simont
My syntax highlighting is done by Jed. It's purely lexical: it distinguishes between keywords, identifiers, numeric literals, string literals, operators, delimiters, comments and preprocessor directives, but nothing cleverer than that. It doesn't do anything at even the syntactic level, let alone semantic; so it can't even tell the difference between a typedef name, a structure tag, a variable, a structure member and a macro, and it certainly wouldn't be able to tell the type or scope or constness of a variable. And it doesn't speak preprocessor, so it won't highlight ifdef branches either.

I could, I suppose, configure it to highlight variables with a particular prefix, since that can be done at the purely lexical level. However, you specified "easily", and it certainly wouldn't qualify as that: I'd have to reimplement chunks of the standard C mode in my .jedrc and have them override the normal version. Also, I'd run out of colours.

As for "should" ... I'm not sure. It's possible that I might find uses for such functionality if it could be easily done; but I've never felt its lack. More generally, one might present various arguments against making syntax highlighting too complicated:
  • it would slow the editor down
  • it would encourage people spending more time configuring their highlighting scheme and less time coding
  • the closer the editor comes to fully understanding the source language, the more people will tend to work on the assumption that it will always agree with the compiler, leading to significantly greater inconvenience on the few occasions when it doesn't
  • writing editor modes for new languages becomes a lot more effort.
On the whole I think I'm happy with the level of highlighting I have now: simple to implement for a new language, quick to perform during editing, and relatively robust in the face of things the editor doesn't understand.