System Macros/Scratch Variables
Because values often need to be saved only temporarily, ConTeXt defines the <counter>
\scratchcounter. This is a real <counter>, and not a pseudo one, as we will meet further on. Analogous scratch registers are
\scratchbox. You can use these registers in your own macro code, but a warning is in order:
Do not expect it to be safe to use any of the scratch registers across any call to any internal ConTeXt macro. While ConTeXt is supposed to make sure that the scratch registers it needs are initialized on entry to the internal macro, it doesn't bother to restore the original value when it returns from that macro, so you never know what will be in any scratch register afterwards.
ConTeXt uses a rather large collection of other scratch registers itself. Their names all look like this:
XXXXX is something like 'count' or 'depth', and
Y is a letter starting from
\!!counta). The fact that their names start with
!! is a clear statement: Don't touch them, it's dangerous. If you need extra scratch registers, define your own.
ConTeXt uses another large set of 'scratch' commands to store all sorts of string values in, because if you have to repeat them more than once inside a macro definition, then macro names occupy less space in TeX's memory than the strings themselves).
For this reason, you should not define or alter macro names that start with
\s!: These are macros holding system constants, i.e. values that never change
\c!: These are macros holding constant keys in key-value pairs. The actual definitions depend on the multi-lingual interface that is currently being used
\v!: These are macros holding names of variable values in key-value pairs. The actual definitions depend on the multi-lingual interface that is currently being used
\??: These are multi-lingual interface constant calls.
\@@: These are results of a multi-lingual interface constant expansion.
By far the safest approach to defining your own scratch macros is to make them mixed case.