Changeset 13338
- Timestamp:
- 06/17/11 07:01:10 (12 years ago)
- Location:
- trunk/abcl/doc/manual
- Files:
-
- 4 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/doc/manual/abcl.tex
r13335 r13338 1 % TODO 2 % 1. Create mechanism for swigging DocString and Lisp docs into 3 % sections. 4 5 6 \documentclass[10pt]{article} 7 8 \usepackage{color,hyperref} 9 \definecolor{darkblue}{rgb}{0.0,0.0,0.3} 10 \hypersetup{colorlinks,breaklinks, 11 linkcolor=darkblue,urlcolor=darkblue, 12 anchorcolor=darkblue,citecolor=darkblue} 13 14 \usepackage{a4wide} 1 % http://en.wikibooks.org/wiki/LaTeX/ 2 3 \include{index.sty} 15 4 16 5 \begin{document} 17 6 \title{A Manual for Armed Bear Common Lisp} 18 \date{June 1 6, 2011}7 \date{June 17, 2011} 19 8 \author{Mark Evenson, Erik Huelsmann, Alessio Stallo, Ville Voutilainen} 20 9 … … 26 15 \section{Obtaining} 27 16 17 \subsection{Source Repositories} 18 19 \begin[shell]{code} 20 svn co http://svn.common-lisp.net/armedbear/trunk abcl 21 \end{code} 22 28 23 \subsection{Requirements} 29 24 … … 31 26 32 27 \subsection{Building from Source} 33 % TODO repeat install 28 29 There are three ways to build ABCL from the source release with the 30 preferred (and most tested way) is to being to use the Ant build tool: 31 32 \begin{itemize} 33 34 \item Use the Ant build tool for Java environments. 35 36 \item Use the Netbeans 6.x IDE to open ABCL as a project. 37 38 \item Bootstrap ABCL using a Common Lisp implementation. Supported 39 implementations for this process: SBCL, CMUCL, OpenMCL, Allegro 40 CL, LispWorks or CLISP. 41 \end{itemize} 42 43 In all cases you need a Java 5 or later JDK (JDK 1.5 and 1.6 have been 44 tested). Just the JRE isn't enough, as you need the Java compiler 45 ('javac') to compile the Java source of the ABCL implementation. 46 47 Note that when deploying ABCL having JDK isn't a requirement for the 48 installation site, just the equivalent JRE, as ABCL compiles directly 49 to byte code, avoiding the need for the 'javac' compiler in deployment 50 environments. 51 52 53 \subsubsection{Using Ant} 54 55 Download a binary distribution [Ant version 1.7.1 or greater][1]. 56 Unpack the files somewhere convenient, ensuring that the 'ant' (or 57 'ant.bat' under Windows) executable is in your path and executable. 58 59 [1]: http://ant.apache.org/bindownload.cgi 60 61 Then simply executing 62 63 \begin[shell]{code} 64 unix$ ant 65 \end{code} 66 67 or 68 69 \begin[shell]{code} 70 dos> ant.bat 71 \end{code} 72 73 from the directory containing this README file will create an 74 executable wrapper ('abcl' under UNIX, 'abcl.bat' under Windows). Use 75 this wrapper to start ABCL. 76 77 78 \subsubsection{Using NetBeans} 79 80 Obtain and install the [Netbeans IDE][2]. One should be able to open 81 the ABCL directory as a project in the Netbeans 6.x application, 82 whereupon the usual build, run, and debug targets as invoked in the 83 GUI are available. 84 85 [2]: http://netbeans.org/downloads/ 86 87 88 \subsubsection{Building from Lisp} 89 90 91 Building from a Lisp is the most venerable and untested way of 92 building ABCL. It produces a "non-standard" version of the 93 distribution that doesn't share build instructions with the previous 94 two methods, but it still may be of interest to those who absolutely 95 don't want to know anything about Java. 96 97 First, copy the file 'customizations.lisp.in' to 'customization.lisp', 98 in the directory containing this README file, editing to suit your 99 situation, paying attention to the comments in the file. The critical 100 step is to have Lisp special variable '*JDK*' point to the root of the 101 Java Development Kit. Underneath the directory referenced by the 102 value of '*JDK*' there should be an exectuable Java compiler in 103 'bin/javac' ('bin/java.exe' under Windows). 104 105 Then, one may either use the 'build-from-lisp.sh' shell script or load 106 the necessary files into your Lisp image by hand. 107 108 \paragraph{Using the 'build-from-lisp.sh' script} 109 110 Under UNIX-like systems, you may simply invoke the 111 'build-from-lisp.sh' script as './build-from-lisp.sh 112 <lisp-of-choice>', e.g. 113 114 \begin[shell]{code} 115 unix$ ./build-from-lisp.sh sbcl 116 \end{code} 117 118 After a successful build, you may use \file{abcl} (\file{abcl.bat} on 119 Windows) to start ABCL. Note that this wrappers contain absolute 120 paths, so you'll need to edit them if you move things around after the 121 build. 122 123 If you're developing on ABCL, you may want to use 124 125 \begin[shell]{code} 126 unix$ ./build-from-lisp.sh <implementation> --clean=nil 127 \end{code} 128 129 to not do a full rebuild. 130 131 In case of failure in the javac stage, you might try this: 132 133 \begin[shell]{code} 134 unix$ ./build-from-lisp.sh <implementation> --full=t --clean=t --batch=nil 135 \end{code} 136 137 This invokes javac separately for each .java file, which avoids running 138 into limitations on command line length (but is a lot slower). 139 140 \subsubsubsection{Building from another Lisp by hand} 141 142 There is also an ASDF definition in 'abcl.asd' for the BUILD-ABCL 143 which can be used to load the necessary Lisp definitions, after which 144 145 \begin[lisp]{code} 146 CL-USER> (build-abcl:build-abcl :clean t :full t) 147 \end{code} 148 149 will build ABCL. If ASDF isn't present, simply LOAD the 150 'customizations.lisp' and 'build-abcl.lisp' files to achieve the same 151 effect as loading the ASDF definition. 34 152 35 153 \subsection{Contributing} … … 50 168 \item Java values are accessible as objects of type JAVA:JAVA-OBJECT. 51 169 \item The Java FFI presents a Lisp package (JAVA) with many useful 52 symbols for manipulating the artifacts of ex ecutation on the JVM,53 including creation of new objects (JAVA:JNEW, JAVA:JMETHOD), the54 introspection of values (JAVA:JFIELD), the execution of methods55 ( JAVA:JCALL, JAVA:JCALL-RAW, JAVA:JSTATIC)56 \item The JSS package ( JSS) in contrib introduces a convenient macro57 syntax (JSS:SHARPSIGN_HASH_DOUBLQUOTE_MACRO)for accessing Java58 methods, and additional convenience fun tions.170 symbols for manipulating the artifacts of expectation on the JVM, 171 including creation of new objects \ref{JAVA:JNEW}, \ref{JAVA:JMETHOD}), the 172 introspection of values \ref{JAVA:JFIELD}, the execution of methods 173 (\ref{JAVA:JCALL}, \ref{JAVA:JCALL-RAW}, \ref{JAVA:JSTATIC}) 174 \item The JSS package (\ref{JSS}) in contrib introduces a convenient macro 175 syntax \ref{JSS:SHARPSIGN_DOUBLEQUOTE_MACRO} for accessing Java 176 methods, and additional convenience functions. 59 177 \item Java classes and libraries may be dynamically added to the 60 178 classpath at runtime (JAVA:ADD-TO-CLASSPATH). … … 67 185 68 186 \begin{itemize} 69 \item All Lisp values are descend ents of LispObject.java70 \item Lisp symbols are accessible via either directly referen ing the187 \item All Lisp values are descendants of LispObject.java 188 \item Lisp symbols are accessible via either directly referencing the 71 189 Symbol.java instance or by dynamically introspecting the 72 190 corresponding Package.java instance. 73 \item The Lisp dynamic env rionment may be saved via74 LispThread.bindSpecial(BINDING)and restored via191 \item The Lisp dynamic environment may be saved via 192 \code{LispThread.bindSpecial(BINDING)} and restored via 75 193 LispThread.resetSpecialBindings(mark). 76 194 \item Functions may be executed by invocation of the … … 80 198 \subsubsection{Lisp FFI} 81 199 82 FFI stands for "Foreign Function Interface", which is the way the 83 contemporary Lisp world refers to methods of "calling out" from Lisp 84 into "foreign" langauges and envrionments. This document describes 85 the various ways that one interacts with Lisp world of Abcl from Java, 86 considering the hosted Lisp as the "Foreign Function" that needs to be 87 "Interfaced". 88 200 FFI stands for "Foreign Function Interface" which is the phase which 201 the contemporary Lisp world refers to methods of "calling out" from 202 Lisp into "foreign" languages and environments. This document 203 describes the various ways that one interacts with Lisp world of ABCL 204 from Java, considering the hosted Lisp as the "Foreign Function" that 205 needs to be "Interfaced". 89 206 90 207 \subsubsubsection{Calling Lisp from Java} … … 92 209 Note: As the entire ABCL Lisp system resides in the org.armedbear.lisp 93 210 package the following code snippets do not show the relevant import 94 statements in the interest of brevity. 211 statements in the interest of brevity. An example of the import 212 statement would be 213 214 \begin[java]{code} 215 import org.armedbear.lisp.*; 216 \end{document} 217 218 to potentially import all the JVM symbol from the `org.armedbear.lisp' 219 namespace. 95 220 96 221 Per JVM, there can only ever be a single Lisp interpreter. This is 97 222 started by calling the static method `Interpreter.createInstance()`. 98 223 99 \begin {code}{java}100 Interpreter interpreter = Interpreter.createInstance();224 \begin[java]{code} 225 Interpreter interpreter = Interpreter.createInstance(); 101 226 \end{code} 102 227 103 228 If this method has already been invoked in the lifetime of the current 104 229 Java process it will return null, so if you are writing Java whose 105 life cycle is a bit out of your control (like in a Java servlet), a230 life-cycle is a bit out of your control (like in a Java servlet), a 106 231 safer invocation pattern might be: 107 232 108 \begin {code}{java}109 Interpreter interpreter = Interpreter.getInstance();110 if (interpreter == null) {111 interpreter = Interpreter.createInstance();112 }113 \end{code} 114 115 116 117 The Lisp `EVAL`primitive may be simply passed strings for evaluation,233 \begin[java]{code} 234 Interpreter interpreter = Interpreter.getInstance(); 235 if (interpreter == null) { 236 interpreter = Interpreter.createInstance(); 237 } 238 \end{code} 239 240 241 242 The Lisp \code{eval} primitive may be simply passed strings for evaluation, 118 243 as follows 119 244 120 \begin{code}{java} 121 String line = "(load \"file.lisp\")"; 122 LispObject result = interpreter.eval(line); 123 \end{code} 124 245 \begin[java]{code} 246 String line = "(load \"file.lisp\")"; 247 LispObject result = interpreter.eval(line); 248 \end{code} 125 249 126 250 Notice that all possible return values from an arbitrary Lisp … … 128 252 further computation on the `LispObject` depends on knowing what the 129 253 result of the computation might be, usually involves some amount 130 of instanceofintrospection, and forms a whole topic to itself254 of \code{instanceof} introspection, and forms a whole topic to itself 131 255 (c.f. [Introspecting a LispObject](#introspecting)). 132 256 … … 137 261 parameters. 138 262 139 \begin {code}{java}263 \begin[java]{code} 140 264 interpreter.eval("(defun foo (msg) (format nil \"You told me '~A'~%\" msg))"); 141 265 Package pkg = Packages.findPackage("CL-USER"); … … 153 277 tell if a `LispObject` contains a reference to a symbol. 154 278 155 \begin {code}{java}279 \begin[java]{code} 156 280 boolean nullp(LispObject object) { 157 281 LispObject result = Primitives.NULL.execute(object); … … 161 285 return true; 162 286 } 163 164 \end{code} 165 166 /subsubsubsection{Introspecting a LispObject}287 \end{code} 288 289 \paragraph{Introspecting a LispObject} 290 \label{topic:Introspecting a LispObject} 167 291 168 292 We present various patterns for introspecting an an arbitrary … … 170 294 into semantics that Java can meaniningfully deal with. 171 295 172 /subsubsubsubsection{LispObject as \java{boolean}}296 \paragragh{LispObject as \code{boolean}} 173 297 174 298 If the LispObject a generalized boolean values, one can use 175 299 \java{getBooleanValue()} to convert to Java: 176 300 177 \begin {code}{java}301 \begin[java]{code} 178 302 LispObject object = Symbol.NIL; 179 303 boolean javaValue = object.getBooleanValue(); … … 183 307 use of Java equality it quite a bit easier and more optimal: 184 308 185 \begin {code}{java}309 \begin[java]{code}} 186 310 boolean javaValue = (object != Symbol.NIL); 187 311 \end{code} 188 312 189 /subsubsubsubsection{LispObject is a list}313 \subsubsubsubsection{LispObject is a list} 190 314 191 315 If LispObject is a list, it will have the type `Cons`. One can then use 192 the `copyToArray[]`to make things a bit more suitable for Java316 the \code{copyToArray} to make things a bit more suitable for Java 193 317 iteration. 194 318 195 \begin {code}{java}319 \begin[java]{code} 196 320 LispObject result = interpreter.eval("'(1 2 4 5)"); 197 321 if (result instanceof Cons) { … … 204 328 function just as like one would traverse a list in Lisp:; 205 329 206 \begin {code}{java}330 \begin[java]{code} 207 331 LispObject result = interpreter.eval("'(1 2 4 5)"); 208 332 while (result != Symbol.NIL) { … … 228 352 % TODO go through AMOP with symbols, starting by looking for 229 353 % matching function signature. 354 % XXX is this really blocking ANSI conformance? Answer: we have 355 % to start with such a ``census'' to determine what we have. 230 356 \end{itemize} 231 357 … … 235 361 \section{Extensions} 236 362 237 % TODO document the EXTENSIONS package. 363 The symbols in the EXTENSIONS package consititutes extensions to the 364 ANSI standard that are potentially useful to the user. They include 365 functions for manipulating network sockets, running external programs, 366 registering object finalizers, constructing reference weakly held by 367 the garbage collector and others. 368 369 \include{extensions} 238 370 239 371 \section{Multithreading} 240 372 241 373 % TODO document the THREADS package. 374 \include{threads} 242 375 243 376 \section{History} 244 377 245 378 \end{document} 379 380 % TODO 381 % 1. Create mechanism for swigging DocString and Lisp docs into 382 % sections. 383
Note: See TracChangeset
for help on using the changeset viewer.