Syntax Coloring

The Mathematica editor provides a syntax coloring system to help you see the different parts of your code. It colors strings, comments, and local variables, as well as potential local variable conflicts. Also, symbols that are known to the system are differentiated from package symbols.

If the code is a Mathematica package, the Workbench will keep track of the different elements. This gives some useful features for the syntax coloring system.

A sample of the coloring system is shown below.


The actual colors used can be modified by the Mathematica editor preferences page. The following gives a description of the different types of coloring the Workbench provides.

System Symbols

System symbols, such as Module in the example above, are colored in their own way.

Comments, Strings, and Numbers

Comments, strings, and numbers each have their own color.

Local Variables

Local variables are colored in their own color. An example is y, which is a local variable of the Module. This often helps to check that you have used the correct name. The syntax warning system will give a warning if a local variable is not being used.

Local Variable Conflict

If the same name is used as a local variable in two programming constructs, this is colored. For example, the x is a local variable of both the function definition and the module. These conflicts are good to avoid since their behavior might not be completely as expected.

Package Export

If the code is a Mathematica package the Workbench will keep track of the different elements. For example, a symbol exported from the package, in this case ExportedFun, is colored specially.

Private Package Definition

A symbol that is private to a package, but which is used to make function definitions, is colored specially. An example of this is the definition of localFun.