Skip to content

Commit

Permalink
Workaround for \lstinline math breaking the LaTeXML build
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed May 5, 2020
1 parent 4998b08 commit 0c1efae
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions chapters/overloaded.tex
Expand Up @@ -216,8 +216,13 @@ \section{Overloaded String Conversions}\doublelabel{overloaded-string-conversion

\section{Overloaded Binary Operations}\doublelabel{overloaded-binary-operations}

Let $\mathit{op}$ denote a binary operator and consider an expression
\lstinline[mathescape=true]!a $\mathit{op}$ b! where \lstinline!a! is an instance or array of instances of
% Can't use \mathit{op} in the \lstinline math due to issue reported here:
% https://github.com/brucemiller/LaTeXML/issues/1274
%\newcommand{\theop}{\mathit{op}}
\newcommand{\theop}{X}

Let $\theop$ denote a binary operator and consider an expression
\lstinline[mathescape=true]!a $\theop$ b! where \lstinline!a! is an instance or array of instances of
class \lstinline!A! and \lstinline!b! is an instance or array of instances of
class \lstinline!B!.

Expand All @@ -227,27 +232,27 @@ \section{Overloaded Binary Operations}\doublelabel{overloaded-binary-operations}
corresponding built-in operation is performed.
\item
Otherwise, if there exists \emph{exactly one} function $f$ in the
union of \lstinline!A.$\mathit{op}$! and \lstinline!B.$\mathit{op}$! such that
\lstinline!$f$(a, b)! is a valid match for the function $f$, then
\lstinline!a $\mathit{op}$ b! is evaluated using this function. It is an error, if
multiple functions match. If \lstinline!A! is not an operator record class, \lstinline!A.$\mathit{op}$!
union of \lstinline[mathescape=true]!A.$\theop$! and \lstinline[mathescape=true]!B.$\theop$! such that
\lstinline[mathescape=true]!$f$(a, b)! is a valid match for the function $f$, then
\lstinline[mathescape=true]!a $\theop$ b! is evaluated using this function. It is an error, if
multiple functions match. If \lstinline!A! is not an operator record class, \lstinline[mathescape=true]!A.$\theop$!
is seen as the empty set, and similarly for \lstinline!B!.
\begin{nonnormative}
Having a union of the operators ensures that if \lstinline!A! and \lstinline!B! are the same, each function only appears once.
\end{nonnormative}
\item
Otherwise, consider the set given by $f$ in \lstinline!A.$\mathit{op}$!
Otherwise, consider the set given by $f$ in \lstinline[mathescape=true]!A.$\theop$!
and an operator record class \lstinline!C! (different from \lstinline!B!) with a
constructor, $g$, such that \lstinline!C.'constructor'.$g$(b)! is a valid match, and
\lstinline!f(a, C.'constructor'.$g$(b))! is a valid match; and another set given by
$f$ in \lstinline!B.$\mathit{op}$! and an operator record class \lstinline!D!
constructor, $g$, such that \lstinline[mathescape=true]!C.'constructor'.$g$(b)! is a valid match, and
\lstinline[mathescape=true]!f(a, C.'constructor'.$g$(b))! is a valid match; and another set given by
$f$ in \lstinline[mathescape=true]!B.$\theop$! and an operator record class \lstinline!D!
(different from \lstinline!A!) with a constructor, $h$, such that
\lstinline!D.'constructor'.$h$(a)! is a valid match and \lstinline!$f$(D.'constructor'.$h$(a), b)!
\lstinline[mathescape=true]!D.'constructor'.$h$(a)! is a valid match and \lstinline[mathescape=true]!$f$(D.'constructor'.$h$(a), b)!
is a valid match. If the sum of the sizes of these sets is one this
gives the unique match. If the sum of the sizes is larger than one it
is an error.
\begin{nonnormative}
Informally, this means: If there is no direct match of \lstinline[mathescape=true]!a $\mathit{op}$ b!, then it is tried to find a direct match by automatic type casts
Informally, this means: If there is no direct match of \lstinline[mathescape=true]!a $\theop$ b!, then it is tried to find a direct match by automatic type casts
of \lstinline!a! or \lstinline!b!, by converting either \lstinline!a! or \lstinline!b! to the needed
type using an appropriate constructor function from one of the
operator record classes used as arguments of the overloaded \lstinline!op!
Expand Down Expand Up @@ -309,18 +314,18 @@ \section{Overloaded Binary Operations}\doublelabel{overloaded-binary-operations}

\section{Overloaded Unary Operations}\doublelabel{overloaded-unary-operations}

Let $\mathit{op}$ denote a unary operator and consider an expression
\lstinline[mathescape=true]!$\mathit{op}$ a! where \lstinline!a! is an instance or array of instances of class
\lstinline!A!. Then \lstinline[mathescape=true]!$\mathit{op}$ a! is evaluated in the following way.
Let $\theop$ denote a unary operator and consider an expression
\lstinline[mathescape=true]!$\theop$ a! where \lstinline!a! is an instance or array of instances of class
\lstinline!A!. Then \lstinline[mathescape=true]!$\theop$ a! is evaluated in the following way.

\begin{enumerate}
\item
If \lstinline!A! is a predefined type, then the corresponding built-in
operation is performed.
\item
If \lstinline!A! is an operator record class and there exists a unique
function $f$ in \lstinline!A.$\mathit{op}$! such that \lstinline!A.$\mathit{op}$.$f$(a)! is a valid
match, then \lstinline!$\mathit{op}$ a! is evaluated to \lstinline!A.$\mathit{op}$.$f$(a)!. It is an
function $f$ in \lstinline[mathescape=true]!A.$\theop$! such that \lstinline[mathescape=true]!A.$\theop$.$f$(a)! is a valid
match, then \lstinline[mathescape=true]!$\theop$ a! is evaluated to \lstinline[mathescape=true]!A.$\theop$.$f$(a)!. It is an
error, if there are multiple valid matches.
\item
Otherwise, if \lstinline!a! is an array expression, then the expression
Expand Down

0 comments on commit 0c1efae

Please sign in to comment.