Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

Screenshot

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

share|improve this question
1  
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
add comment

2 Answers

up vote 5 down vote accepted
+50

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
add comment

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 java.decompiler.free.fr/?q=jdgui, but then I got totally lost... –  Ajasja Jan 21 '13 at 12:33
add comment

Your Answer

 
discard

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.