Changes

Jump to navigation Jump to search
m
< '''Prev:''' [[System_MacrosSystem Macros/Mnemonics and Aliases|Mnemonics & Aliases]]| '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Expansion Control|Expansion Control]] >
Because we often need counters on a temporary basis, we define the <''counter''> <code>\scratchcounter</code>. This is a real <''counter''>, and not a pseudo one, as we will meet further on. The others are analogous scratch === Scratch registers.===
A warning is in order here. YesBecause values often need to be saved only temporarily, you can use these registers in your own macrocode. But ConTeXt defines the <''counter''> <code>\scratchcounter</code>. This is a real <'not'counter'' across calls to internal ConTeXt macros>, and not a pseudo one, as we will meet further on. While ConTeXt always makes sure that the Analogous scratch registers are cleared on entry to the call<code>\scratchdimen</code>, <code>\scratchskip</code>, <code>\scratchmuskip</code>, it usually doesn't bother to restore <code>\scratchtoks</code> and <code>\scratchbox</code>. You can use these registers in your user supplied value when it returns.own macro code, but a warning is in order:
ConTeXt also uses a rather large collection Do '''not''' expect it to be safe to use any of other the scratch registers across any call to any internal ConTeXt macro. While ConTeXt is supposed to make sure that the scratch registers. Their names all look like this: <code>\!!XXXXXY</code>it needs are initialized on entry to the internal macro, where <code>XXXXX</code> is something like it doesn'count' or 'depth', and <code>Y</code> is a letter starting t bother to restore the original value when it returns from <code>a</code> (e.g. <code>\!!counta</code>). The fact that their names start with <code>!!</code> is a clear statement: Don't touch themmacro, it's dangerous. If so you need never know what will be in any scratch registers, define your ownregister afterwards.
ConTeXt uses yet another set a rather large collection of constants other scratch registers itself. Their names all look like this: <code>\!!XXXXXY</code>, where <code>XXXXX</code> is something like 'count' or 'depth', and variables to store all sorts of string values in <code>Y</code> is a letter starting from <code>a</code> (macro e.g. <code>\!!counta</code>). The fact that their names occupy less space in TeXstart with <code>!!</code> is a clear statement: Don't touch them, it's memory than the strings themselves)dangerous. If you need extra scratch registers, define your own.
For this reason, you should also not touch the definitions of macros that start with=== Scratch commands ===
* <code>\s!</code> (constant ConTeXt uses another large set of 'scratch' commands to store all sorts of string)values in,* <code>\c!</code> (constant)because if you have to repeat them more than once inside a macro definition,* <code>\p!</code> (parameter),* <code>\v!</code> (variable),* <code>\@@</code> (multi-lingual interface parameter expansion),* <code>\??</code> (multi-lingual interface parameter callthen macro names occupy less space in TeX's memory than the strings themselves).
Redefining these For this reason, you should not define or alter macro names that start with * <code>\s!</code>: These are macros can have disastrous holding ''system constants'', i.e. values that never change* <code>\c!</code>: These are macros holding ''constant keys'' in key-value pairs. The actual definitions depend on the multi-lingual interface that is currently being used* <code>\v!</code>: 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* <code>\??</code>: These are multi-lingual interface constant calls. * <code>\@@</code>: These are resultsof a multi-lingual interface constant expansion. By far the safest approach to defining your own scratch macros is to make them mixed case< '''Prev:''' [[System Macros/Mnemonics and Aliases|Mnemonics & Aliases]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Expansion Control|Expansion Control]] > [[Category:System Macros]][[Category:ConTeXt programming]]

Navigation menu