| 1 |
\documentclass{article} |
| 2 |
|
| 3 |
\usepackage{luacas} |
| 4 |
\usepackage{amsmath} |
| 5 |
\usepackage{amssymb} |
| 6 |
|
| 7 |
\usepackage[margin=1in]{geometry} |
| 8 |
\usepackage[shortlabels]{enumitem} |
| 9 |
|
| 10 |
\usepackage{pgfplots} |
| 11 |
\pgfplotsset{compat=1.18} |
| 12 |
\usetikzlibrary{positioning,calc} |
| 13 |
\usepackage[edges]{forest} |
| 14 |
\usepackage{minted} |
| 15 |
\usemintedstyle{pastie} |
| 16 |
\usepackage[hidelinks]{hyperref} |
| 17 |
\usepackage{parskip} |
| 18 |
\usepackage{multicol} |
| 19 |
\usepackage[most]{tcolorbox} |
| 20 |
\tcbuselibrary{xparse,documentation} |
| 21 |
\usepackage{microtype} |
| 22 |
\usepackage{makeidx} |
| 23 |
|
| 24 |
\usepackage[ |
| 25 |
backend=biber, |
| 26 |
style=numeric, |
| 27 |
]{biblatex} |
| 28 |
\addbibresource{sources.bib} |
| 29 |
|
| 30 |
\definecolor{rose}{RGB}{128,0,0} |
| 31 |
\definecolor{roseyellow}{RGB}{222,205,99} |
| 32 |
\definecolor{roseblue}{RGB}{167,188,214} |
| 33 |
\definecolor{rosenavy}{RGB}{79,117,139} |
| 34 |
\definecolor{roseorange}{RGB}{232,119,34} |
| 35 |
\definecolor{rosegreen}{RGB}{61,68,30} |
| 36 |
\definecolor{rosewhite}{RGB}{223,209,167} |
| 37 |
\definecolor{rosebrown}{RGB}{108,87,27} |
| 38 |
\definecolor{rosegray}{RGB}{84,88,90} |
| 39 |
|
| 40 |
\definecolor{codegreen}{HTML}{49BE25} |
| 41 |
|
| 42 |
\newtcolorbox{codebox}[1][sidebyside]{ |
| 43 |
enhanced,skin=bicolor, |
| 44 |
#1, |
| 45 |
arc=1pt, |
| 46 |
colframe=brown, |
| 47 |
colback=brown!15,colbacklower=white, |
| 48 |
boxrule=1pt, |
| 49 |
notitle |
| 50 |
} |
| 51 |
|
| 52 |
\newtcolorbox{codehead}[1][]{ |
| 53 |
enhanced, |
| 54 |
frame hidden, |
| 55 |
colback=rosegray!15, |
| 56 |
boxrule=0mm, |
| 57 |
leftrule=5mm, |
| 58 |
rightrule=5mm, |
| 59 |
boxsep=0mm, |
| 60 |
arc=0mm, |
| 61 |
outer arc=0mm, |
| 62 |
left=3mm, |
| 63 |
right=3mm, |
| 64 |
top=1mm, |
| 65 |
bottom=1mm, |
| 66 |
toptitle=1mm, |
| 67 |
bottomtitle=1mm, |
| 68 |
oversize, |
| 69 |
#1 |
| 70 |
} |
| 71 |
|
| 72 |
\usepackage{varwidth} |
| 73 |
|
| 74 |
\newtcolorbox{newcodehead}[2][]{ |
| 75 |
enhanced, |
| 76 |
frame hidden, |
| 77 |
colback=rosegray!15, |
| 78 |
boxrule=0mm, |
| 79 |
leftrule=5mm, |
| 80 |
rightrule=5mm, |
| 81 |
boxsep=0mm, |
| 82 |
arc=0mm, |
| 83 |
outer arc=0mm, |
| 84 |
left=3mm, |
| 85 |
right=3mm, |
| 86 |
top=1mm, |
| 87 |
bottom=1mm, |
| 88 |
toptitle=1mm, |
| 89 |
bottomtitle=1mm, |
| 90 |
oversize, |
| 91 |
#1, |
| 92 |
fonttitle=\bfseries\ttfamily\footnotesize, |
| 93 |
coltitle=rosegray, |
| 94 |
attach boxed title to top text right, |
| 95 |
boxed title style={frame hidden,size=small,bottom=-1mm, |
| 96 |
interior style={fill=none, |
| 97 |
top color=white, |
| 98 |
bottom color=white}}, |
| 99 |
title={#2} |
| 100 |
} |
| 101 |
|
| 102 |
\makeindex |
| 103 |
|
| 104 |
\newcommand{\coderef}[2]{% |
| 105 |
\begin{codehead}[sidebyside,segmentation hidden]% |
| 106 |
\mintinline{lua}{#1}% |
| 107 |
\tcblower% |
| 108 |
\begin{flushright}% |
| 109 |
\mintinline{lua}{#2}% |
| 110 |
\end{flushright}% |
| 111 |
\end{codehead}% |
| 112 |
} |
| 113 |
|
| 114 |
\newcommand{\newcoderef}[3]{% |
| 115 |
\begin{newcodehead}[sidebyside,segmentation hidden]{#3}% |
| 116 |
\mintinline{lua}{#1}% |
| 117 |
\tcblower% |
| 118 |
\begin{flushright}% |
| 119 |
\mintinline{lua}{#2}% |
| 120 |
\end{flushright}% |
| 121 |
\end{newcodehead}% |
| 122 |
} |
| 123 |
|
| 124 |
\begin{document} |
| 125 |
\thispagestyle{empty} |
| 126 |
\part{Reference} |
| 127 |
This part contains reference material for the classes and methods that incorporate the \texttt{luacas} package. Some classes are \emph{concrete} while others are \emph{abstract}. The concrete classes are essentially the objects that a user might reasonably interact with while using \texttt{luacas}. Thankfully, most of this interaction will be filtered through a rudimentary (but functional!) parser. Abstract classes exist for the purposes of inheritance. |
| 128 |
|
| 129 |
The classes in the diagram below are color-coded according to: |
| 130 |
\begin{itemize} |
| 131 |
\item (\tikz[baseline=-0.5ex]\node[text=rosenavy,fill=roseblue!40]{\ttfamily\bfseries Class};) {\color{rosenavy}\ttfamily\bfseries Class}: a (concrete) class belonging to the core module; |
| 132 |
\item (\tikz[baseline=-0.5ex]\node[text=rose,fill=rose!30]{\ttfamily\bfseries Class};) {\color{rose}\ttfamily\bfseries Class}: a (concrete) class belonging to the algebra module; |
| 133 |
\item (\tikz[baseline=-0.5ex]\node[text=roseorange,fill=roseorange!30]{\ttfamily\bfseries Class};) {\color{roseorange}\ttfamily\bfseries Class}: a (concrete) class belonging to the calculus module. |
| 134 |
\end{itemize} |
| 135 |
Inheritance is indicated with an arrow: |
| 136 |
|
| 137 |
\forestset{multiple directions/.style={for tree={#1}, phantom, for relative level=1{no edge, delay={!c.content/.pgfmath=content("!u")}, before computing xy={l=0,s=0}}}, |
| 138 |
multiple directions/.default={}, |
| 139 |
grow subtree/.style={for tree={grow=#1}}, |
| 140 |
grow' subtree/.style={for tree={grow'=#1}}} |
| 141 |
|
| 142 |
\begin{center} |
| 143 |
\begin{forest} |
| 144 |
core/.style = {draw={rosenavy,thick}, |
| 145 |
font={\ttfamily\bfseries\color{rosenavy}}, |
| 146 |
fill = roseblue!#1}, |
| 147 |
algebra/.style = {draw={rose,thick}, |
| 148 |
font={\ttfamily\bfseries\color{rose}}, |
| 149 |
fill = rose!#1}, |
| 150 |
calculus/.style = {draw={roseorange,thick}, |
| 151 |
font={\ttfamily\bfseries\color{roseorange}}, |
| 152 |
fill = roseorange!#1}, |
| 153 |
multiple directions, |
| 154 |
for tree = {font = \ttfamily\bfseries, |
| 155 |
draw, |
| 156 |
rounded corners=1pt, |
| 157 |
edge = {-stealth}, |
| 158 |
s sep = 0.2cm} |
| 159 |
[Expression |
| 160 |
[, grow subtree = 90 |
| 161 |
[AtomicExpression, |
| 162 |
core = {0}, |
| 163 |
for tree = {grow=east, |
| 164 |
child anchor=west, |
| 165 |
node options={anchor=west}}, |
| 166 |
forked edges, |
| 167 |
calign=last, |
| 168 |
l sep = 0.5cm, |
| 169 |
s sep = 0.2cm |
| 170 |
[SymbolExpression, |
| 171 |
core={50}] |
| 172 |
[ConstantExpression, |
| 173 |
core ={0}, |
| 174 |
for tree = {grow = north, |
| 175 |
node options = {anchor=north} |
| 176 |
} |
| 177 |
[Ring, |
| 178 |
algebra ={0}, |
| 179 |
for tree = {grow = east} |
| 180 |
[EuclideanDomain, |
| 181 |
algebra={0} |
| 182 |
[Field, |
| 183 |
algebra = {0} |
| 184 |
[IntegerModN, |
| 185 |
algebra={30}] |
| 186 |
[Rational, |
| 187 |
algebra={30}] |
| 188 |
] |
| 189 |
[Integer, |
| 190 |
algebra={30}] |
| 191 |
] |
| 192 |
[PolynomialRing, |
| 193 |
algebra={30}] |
| 194 |
] |
| 195 |
] |
| 196 |
]] |
| 197 |
[, grow subtree = -90 |
| 198 |
[CompoundExpression, |
| 199 |
core = {0}, |
| 200 |
for tree = {grow=east, |
| 201 |
child anchor=west, |
| 202 |
node options={anchor=west}},forked edges, |
| 203 |
calign=last, |
| 204 |
l sep = 0.5cm, |
| 205 |
s sep = 0.2cm |
| 206 |
[FunctionExpression, |
| 207 |
core = {40} |
| 208 |
[TrigExpression,algebra={30}] |
| 209 |
] |
| 210 |
[BinaryOperation, |
| 211 |
core = {40}] |
| 212 |
[Equation, |
| 213 |
algebra = {30}] |
| 214 |
[Logarithm, |
| 215 |
algebra={30}] |
| 216 |
[FactorialExpression, |
| 217 |
algebra={30}] |
| 218 |
[RootExpression, |
| 219 |
algebra={30}] |
| 220 |
[SqrtExpression, |
| 221 |
algebra={30}] |
| 222 |
[AbsExpression, |
| 223 |
algebra={30}] |
| 224 |
[DerivativeExpression, |
| 225 |
calculus={20}] |
| 226 |
[DiffExpression, |
| 227 |
calculus={20}] |
| 228 |
[IntegralExpression, |
| 229 |
calculus={20}] |
| 230 |
]] |
| 231 |
] |
| 232 |
\end{forest} |
| 233 |
\end{center} |
| 234 |
Every object in \texttt{luacas} is an expression, meaning it inherits from the {\ttfamily Expression} type (class). Since the {\ttfamily Expression} type itself has no constructor and cannot be instantiated, it it closer to an interface in Java OOP terms.\footnote{In reality, interfaces are unnecessary in Lua due to its weak typing - Lua doesn't check whether an object has a method at compile time. The {\ttfamily Expression} type is really an abstract class in Java terms.} {\ttfamily Expression}s can store any number of other expressions as sub-expressions, depending on type. This means that {\ttfamily Expression} objects are really trees. Types that inherit from {\ttfamily Expression} that can not store other expressions are called \emph{atomic expressions}, and correspond to the leaf nodes of the tree. Other expression types are \emph{compound expressions}. Thus, every {\ttfamily Expression} type inherits from one of {\ttfamily AtomicExpression} or {\ttfamily CompoundExpression}. The {\ttfamily ConstantExpresssion} interface is a subinterface to {\ttfamily AtomicExpression}. Types that inherit from {\ttfamily ConstantExpression} roughly correspond to numbers (interpreted broadly). |
| 235 |
|
| 236 |
\end{document} |