Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Lately I've been working quite a lot with Compile. I also started using Wolfram Workbench.

So a natural question arises: Is it possible to have syntax highlighting for local variable variables inside compile as well? Here is a screenshot demonstrating the problem. Notice the blue x's in the lower right hand side of the image? These should be green.


I didn't manage to find anything under the preferences. I'm using WB 2.0

share|improve this question
Someone from WRI has to answer/fix this. In the meanwhile I would just use a simple trick and put a Block around, e.g.: cf = Block[ {x}, Compile[{{x, _Real}}, Sin[x] + x^2 - 1/(1 + x)] ] – Rolf Mertig Jan 21 '13 at 10:44
@RolfMertig That's actually not a bad idea. Does this have any performance or any other side effects? – Ajasja Jan 21 '13 at 12:34
no, it just evaluates to its body, so all is good. – Rolf Mertig Jan 21 '13 at 12:38
@RolfMertig Could you put that as an answer? I think this is what I'll end up doing. – Ajasja Jan 21 '13 at 12:45
up vote 5 down vote accepted

Until (when, WRI??) there will be an update of WWB (which certainly will also fix other shortcomings and bugs) just use Block to get the coloring right:

Mathematica graphics

share|improve this answer

As far as I know, you cannot change this. I cannot exactly say how it works in Eclipse, but usually the highlighting process consists of several steps. Basic highlighting can be provided after the lexical analysis. For a context sensitive highlighting like the one for local variables inside Module, Block, Function or in your case Compile, you need to parse the input.

If you are using the Workbench plugin for Eclipse, you can at least get an idea where and how this is implemented. In the plugins directory (in OSX) inside your Eclipse installation path you should find directories for the Wolfram plugin. If you dig a bit in the lib directory there, you'll find that an antlr parser was created to parse Mathematica code. With the help of this parser highlighting and error/warning features are implemented and provided for Eclipse inside the MEET.jar.

To change the behaviour for Compile, you would have to change it inside the MEET code which you don't have access to since the jar files contain (almost) only byte-code.

share|improve this answer
Yes, I did manage to get that far and even got a look inside using, but then I got totally lost... – Ajasja Jan 21 '13 at 12:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.