pub struct Tag(/* private fields */);
Expand description
A tag is a piece of metadata that is optionally attached to a command.
Tags are used to implement certain TeX language semantics.
An example is TeX conditionals.
When a TeX conditional statement evaluates to false, the \if
command must scan
the input stream until it finds either an \else
or \fi
command.
(The tokens scanned in this process are in the true branch of the conditional,
and must thus be discarded.)
Tags are the mechanism by which the scanning algorithm can
determine if a token corresponds to an \else
of \fi
command.
Concretely, both \else
of \fi
command have unique tags associated to them.
When scanning the stream,
if a token is a command token then the tag for the associated command is
compared to the known tags for \else
and \fi
.
If the tags match, the true branch is finished.
In general, TeX commands interface with the VM in two ways. The first most common way is when the main VM loop or expansion loop encounters a command. The loop invokes the command’s associated Rust function. One can think of the Rust function as providing the behavior of the command in this context.
The second way is when a different command, like a conditional command, performs some operation
that is dependent on the commands it reads out of the input stream.
In this context the commands in the input stream provide behavior using tags.
The \else
command having the specific else tag results in the conditional branch processing completing.
Note that the same tag can be used for multiple commands, but each command can only have one tag.
Implementation details
Tags are non-zero 32 bit integers.
The first tag created has value 1, the second tag has value 2, and so on.
A global mutex is used to store the next tag value.
Tags have the property that Option<Tag>
takes up 4 bytes in memory.
Implementations§
Trait Implementations§
source§impl Ord for Tag
impl Ord for Tag
source§impl PartialOrd<Tag> for Tag
impl PartialOrd<Tag> for Tag
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more