A DefMath presentation, Perl DefMathI’s $presentation: TeX source text, tokenized at
definition, or the tokens a binding built (amsopn’s Invocation(T_CS('\operatorname'), $star, $text)), which keep their catcodes and are dispatched on them (Package.pm:1650-1661).
Perl defmath_wrapped (Package.pm:1786-1813): no arguments, but a presentation naming control
sequences. \cs expands to \cs@wrapper{\cs@presentation}, the presentation macro holds the
tokens as given, and the wrapper constructor puts their digested form in an XMWrap carrying the
DefMath’s attributes (name, meaning, role, scriptpos, stretchy, …), which the math parser moves
onto the parsed content (MathParser.pm:333-360, parser.rs). It reverts as its argument, or as
\cs in a dual’s content branch.
latex.ltx:15386 fires env/#1/end only \IfHookEmptyTF-guarded (an empty
hook must contribute nothing inside an alignment’s last cell): the kernel’s
own predicate, hook_has_code.
\end{name}’s hooks: the pre-\AddToHook\AtEndEnvironment store (@environment@name@atend, filled by
bindings: deluxetable’s table end), then \UseHook{env/name/end} (latex.ltx:15386-15388) when it has code.
end_hook is that invocation if the caller built it already.
Whether the kernel hook hook holds code: HookStore::has_code.
Checks l3_hooks_loaded() first and probes with non-interning Token::try_cs
so checking an empty/undeclared hook never permanently interns 3 SymStrs.
The tokens running the kernel hook hook as \UseHook (or, once, \UseOneTimeHook) does, or none when it has
no code: an empty \UseHook does nothing; an empty one-time hook only marks itself used (\__hook_use_once_set:n,
latex.ltx:6399-6411, so later code runs at once), which an already used one needs not. Not kept: the clear code
\__hook_use_once:nn leaves in an undeclared hook’s next slot, which only \IfHookEmptyTF on it would see.
\begin’s TeX record of the environment it opens, in its group: latex.ltx:15349-15351 \def\@currenvir{#1}\edef\@currenvline{\on@line}. Perl (Package.pm:1927, latex_constructs.pool.ltxml:186-188) leaves \@currenvline\@empty, so \@badend and a hook read no line (OXIDIZED_DESIGN_DIVERGENCES #1242).