slatex / sTeX

A semantic Extension of TeX/LaTeX
49 stars 9 forks source link

MathStructure fields as accessor functions outside of the inner module #363

Open Jazzpirate opened 1 year ago

Jazzpirate commented 1 year ago

given a mathstructure

\begin{smodule}{category}
 \symdef{obj}{\mathtt{obj}}
 ...

we want the fields (e.g. obj) to be accessible outside of the nested module as accessor functions. This eliminates a lot of boilerplace with respect to \usemodule and "nested mathstructures" (think Functor { C : Category, D : Category}), but poses the new challenge of differing arities and notations depending on whether one is "inside" or "outside" the mathstructure.

=> Need something like

\begin{mathstructure}{category}
  \symdef{obj}{\mathtt{obj}_{\thisinstance}}
  ...

where \thisinstance expands to either nothing or the structure whose field this is (e.g. in \vC{obj}) , or #1 on the "outside" (e.g. \obj{\vC!})