|
@@ -28,6 +28,10 @@
|
28
|
28
|
\tableofcontents
|
29
|
29
|
\end{frame}
|
30
|
30
|
|
|
31
|
+\begin{frame}
|
|
32
|
+ \frametitle{Get it here!}
|
|
33
|
+ \href{https://gitlab.com/azrazalea/lisp-game-dev-presentation}{https://gitlab.com/azrazalea/lisp-game-dev-presentation}
|
|
34
|
+\end{frame}
|
31
|
35
|
\section{What is lisp?}
|
32
|
36
|
|
33
|
37
|
\begin{frame}
|
|
@@ -39,20 +43,117 @@
|
39
|
43
|
|
40
|
44
|
\begin{frame}[fragile]
|
41
|
45
|
\frametitle{An example}
|
42
|
|
- \begin{minted}[gobble=4,fontsize=\footnotesize]{cl}
|
|
46
|
+\begin{minted}[gobble=4,fontsize=\footnotesize]{cl}
|
43
|
47
|
;; From http://rosettacode.org/wiki/Fibonacci_sequence
|
44
|
48
|
(defun fibonacci-tail-recursive (n &optional (a 0) (b 1))
|
45
|
49
|
(if (= n 0)
|
46
|
50
|
a
|
47
|
51
|
(fibonacci-tail-recursive (- n 1) b (+ a b))))
|
48
|
|
- \end{minted}
|
|
52
|
+\end{minted}
|
|
53
|
+\end{frame}
|
|
54
|
+
|
|
55
|
+\begin{frame}
|
|
56
|
+ \frametitle{Lisp Implementations}
|
|
57
|
+ \begin{itemize}
|
|
58
|
+ \item Common Lisp is an ansi standard.
|
|
59
|
+ \item There are many implementations of this standard, both commercial and open source.
|
|
60
|
+ \item The current most popular appear to be \href{http://sbcl.org/}{SBCL} and \href{http://ccl.clozure.com/}{CCL}.
|
|
61
|
+ \item There are many differences between implementations, but they are generally easy to deal with using libraries built for the purpose.
|
|
62
|
+ \end{itemize}
|
|
63
|
+\end{frame}
|
|
64
|
+
|
|
65
|
+\begin{frame}
|
|
66
|
+ \frametitle{Lisp Libraries}
|
|
67
|
+ \begin{itemize}
|
|
68
|
+ \item Quicklisp is the library manager for Lisp. \href{https://beta.quicklisp.org}{https://beta.quicklisp.org}.
|
|
69
|
+ \item While still marked as ``beta'' it is stable and usable. It just lacks some features the author wants to add before considering it released.
|
|
70
|
+ \item Coolest feature is the ability to install + load libraries completely from the Lisp repl without restarting the process.
|
|
71
|
+ \end{itemize}
|
49
|
72
|
\end{frame}
|
50
|
73
|
|
51
|
74
|
\section{Useful Lisp Features}
|
52
|
75
|
|
|
76
|
+\begin{frame}[fragile]
|
|
77
|
+ \frametitle{Compiled and Interpreted (simultaneously)}
|
|
78
|
+\begin{minted}{lisp}
|
|
79
|
+ (disassemble (defun add () (+ 2 4)))
|
|
80
|
+; disassembly for ADD
|
|
81
|
+; Size: 22 bytes. Origin: #x1003BA0A04
|
|
82
|
+; 04: 498B4C2460 MOV RCX, [R12+96] ; thread.binding-stack-pointer
|
|
83
|
+ ; no-arg-parsing entry point
|
|
84
|
+; 09: 48894DF8 MOV [RBP-8], RCX
|
|
85
|
+; 0D: BA0C000000 MOV EDX, 12
|
|
86
|
+; 12: 488BE5 MOV RSP, RBP
|
|
87
|
+; 15: F8 CLC
|
|
88
|
+; 16: 5D POP RBP
|
|
89
|
+; 17: C3 RET
|
|
90
|
+; 18: CC10 BREAK 16 ; Invalid argument count trap
|
|
91
|
+\end{minted}
|
|
92
|
+\end{frame}
|
|
93
|
+
|
53
|
94
|
\begin{frame}
|
54
|
|
- \frametitle{Dummy}
|
|
95
|
+ \frametitle{"Gradual Typing"}
|
|
96
|
+ \begin{itemize}
|
|
97
|
+ \item Can declare types of arguments and function returns values. Commonly only argument types are declared.
|
|
98
|
+ \item Type system integrated with Object System, used for generics/method dispatch.
|
|
99
|
+ \item In SBCL types are verified at compile time in certain cases, some other implementations only verify at run time.
|
|
100
|
+ \item SBCL will use types to optimize the compiled code, resulting in large performance improvements in some cases.
|
|
101
|
+ \item Unfortunately compile-time checking is not that advanced, mostly only catches constants/literals.
|
|
102
|
+ \end{itemize}
|
|
103
|
+\end{frame}
|
55
|
104
|
|
|
105
|
+\begin{frame}[fragile]
|
|
106
|
+ \frametitle{Types Example}
|
|
107
|
+\begin{minted}{lisp}
|
|
108
|
+(declaim (ftype (function
|
|
109
|
+ (number number)
|
|
110
|
+ number) add))
|
|
111
|
+(defun add (x y)
|
|
112
|
+ (declare (number x y))
|
|
113
|
+ (the number (+ x y)))
|
|
114
|
+; NIL
|
|
115
|
+(add 1 2)
|
|
116
|
+; 3
|
|
117
|
+(add "string" 2)
|
|
118
|
+; The value "string" is not of type NUMBER.
|
|
119
|
+\end{minted}
|
56
|
120
|
\end{frame}
|
57
|
121
|
|
|
122
|
+\begin{frame}
|
|
123
|
+ \frametitle{Object System}
|
|
124
|
+ \begin{itemize}
|
|
125
|
+ \item Classes have slots (``instance variables'')
|
|
126
|
+ \item Methods are defined in terms of generic functions.
|
|
127
|
+ \item Uses multiple dispatch instead of single.
|
|
128
|
+ \item Has multiple inheritance.
|
|
129
|
+ \item Has cool :before, :after, and :around methods
|
|
130
|
+ \item Super dynamic, can change class definitions at runtime even when instances already exist.
|
|
131
|
+ \end{itemize}
|
|
132
|
+\end{frame}
|
|
133
|
+
|
|
134
|
+\begin{frame}[fragile]
|
|
135
|
+ \frametitle{Simple CLOS Example}
|
|
136
|
+\begin{minted}[fontsize=\footnotesize]{lisp}
|
|
137
|
+(defclass dog ()
|
|
138
|
+ ((name :reader name :initarg :name :type string)
|
|
139
|
+ (age :accessor age :type fixnum :initarg :age)))
|
|
140
|
+(defgeneric speak (thing))
|
|
141
|
+(defmethod speak ((rover dog))
|
|
142
|
+ (dotimes (times (age rover))
|
|
143
|
+ (format t "~A SPEAK!~%" (name rover))
|
|
144
|
+ (format t "WOOF!~%")))
|
|
145
|
+(let ((our-dog
|
|
146
|
+ (make-instance 'dog :name "Stupid dog!" :age 1)))
|
|
147
|
+ (speak our-dog)
|
|
148
|
+ ; Stupid dog! SPEAK!
|
|
149
|
+ ; WOOF!
|
|
150
|
+ (incf (age our-dog))
|
|
151
|
+ (speak our-dog)
|
|
152
|
+ ; Stupid dog! Speak!
|
|
153
|
+ ; WOOF!
|
|
154
|
+ ; Stupid dog! Speak!
|
|
155
|
+ ; WOOF!
|
|
156
|
+ )
|
|
157
|
+\end{minted}
|
|
158
|
+\end{frame}
|
58
|
159
|
\end{document}
|