slatex / sTeX

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

Funny behavior with precedences #380

Open kohlhase opened 1 year ago

kohlhase commented 1 year ago

There is still a problem with bracketing, ... Here is a MWE:

\documentclass{stex}
\begin{document}
\begin{smodule}{foo}
  \symdef{limpl}[args=ai,op=\Rightarrow,prec=500;499x499,assoc=binr,name=implication]
  {#1\comp\Rightarrow #2}{##1\comp{\Rightarrow}##2}
  \def\bC{\mathbf{C}}
%  \vardef{bC}{\comp C}
    $\limpl{\limpl{\bC,\limpl\bC\bC}\bC,\limpl{\bC,\bC}\bC,\bC}\bC$
    \end{smodule}
\end{document}

When I use the \def\bC{\mathbf{C}}, then I get

Screenshot 2022-12-08 at 06 45 10

(note the missing brackets) and when I use \vardef{bC}{\comp C} I get

Screenshot 2022-12-08 at 06 46 37

Is this really intended?

Jazzpirate commented 1 year ago

this is indeed weird - since either way the brackets are around an \limpl\bC\bC, whether to insert them should be governed by \limpl rather than \bC, so one would think that the definition of \bC doesn't matter...

Jazzpirate commented 1 year ago

I will recheck the bracketing-algorithm for associative arguments, I'm assuming it treats the whole argument sequence as one (accumulated) argument. Not entirely sure why that would cause the problem, but that seems like a likely cause to me. If that's the problem, I'll fix it for sTeX 3.4

kohlhase commented 1 year ago

That is soon enough, I know how to get the behavior I want.