This example is obviously not useful on its own, but it will cover everything I actually need to know for a more complicated function I'm making.
The example is to recreate the Do
function, and call it Do2
. My code is as follows:
Do2[function_, iterator_] := Do[function, Evaluate[iterator]]
SetAttributes[Do2, HoldAll]
This works correctly as expected, i.e. the functionality of Do2
is exactly the same as the functionality of Do
(I think). However, the syntax highlighting is clearly different for the two functions:
Do2's iterator i is blue, but Do's iterator i is cyan.
Using the "Why the Coloring?" tool under Help, you can see that:
the i
of Do
is under "Variables made special by use in arguments",
but the i
in my Do2
is under "Global symbols that have no value assigned".
How do I get the i
of Do2
to be under "Variables made special by use in arguments"? It seems like it should be under this category, and that the highlighting is wrong.