Changeset 13438
- Timestamp:
- 08/05/11 09:30:50 (12 years ago)
- Location:
- trunk/abcl/doc/manual
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/doc/manual/abcl.sty
r13437 r13438 4 4 % leaving the manual itself as much as a pure content to be 5 5 % comfortably read and modified with a text editor. 6 7 \documentclass[10pt]{article}8 6 9 7 \usepackage{color,hyperref} … … 22 20 23 21 24 \newenvironment{xx}[1]% 25 {\begin{lstlisting} }% 26 {\end{lstlisting}} 22 \lstnewenvironment{listing-java} 23 {\lstset{language=Java}} 24 {} 25 26 27 \lstnewenvironment{listing-lisp} 28 {\lstset{language=Lisp}} 29 {} 27 30 28 31 \usepackage{verbatim} 29 32 33 \ProvidesPackage{abcl} -
trunk/abcl/doc/manual/abcl.tex
r13437 r13438 1 % -*- mode: latex; -*- 1 2 % http://en.wikibooks.org/wiki/LaTeX/ 2 \include{index} 3 \documentclass[10pt]{book} 4 \usepackage{abcl} 3 5 4 6 \begin{document} 5 7 \title{A Manual for Armed Bear Common Lisp} 6 8 \date{August 4, 2011} 7 \author{Mark Evenson, Erik Huelsmann, Alessio Stallo, Ville Voutilainen} 8 9 \section{Introduction} 9 \author{Mark~Evenson, Erik~Huelsmann, Alessio~Stallo, Ville~Voutilainen} 10 11 \maketitle 12 13 \chapter{Introduction} 10 14 11 15 Armed Bear is a mostly conforming implementation of the ANSI Common … … 16 20 This manual corresponds to abcl-0.27.0, as yet unreleased. 17 21 18 19 \section{Interaction with host JVM} 22 \chapter{Conformance} 23 24 25 \section{ANSI Common Lisp} 26 ABCL is currently a non-conforming ANSI Common Lisp implementation due 27 to the following (known) issues: 28 29 \begin{itemize} 30 \item Lack of long form of DEFINE-METHOD-COMBINATION 31 \item Missing statement of conformance in accompanying documentation 32 \end{itemize} 33 34 ABCL aims to be be a fully conforming ANSI Common Lisp 35 implementation. Any other behavior should be reported as a bug. 36 37 \section{Contemporary Common Lisp} 38 In addition to ANSI conformance, ABCL strives to implement features 39 expected of a contemporary Common Lisp. 40 \begin{itemize} 41 \item Incomplete MOP 42 % N.B. 43 % TODO go through AMOP with symbols, starting by looking for 44 % matching function signature. 45 % XXX is this really blocking ANSI conformance? Answer: we have 46 % to start with such a ``census'' to determine what we have. 47 \item Incomplete Gray Streams 48 \end{itemize} 49 50 \chapter{Interaction with host JVM} 20 51 21 52 % describe calling Java from Lisp, and calling Lisp from Java, … … 24 55 % that are more comforable with Lisp 25 56 26 \s ubsection{Lisp to Java}57 \section{Lisp to Java} 27 58 28 59 ABCL offers a number of mechanisms to manipulate Java libraries from … … 43 74 \end{itemize} 44 75 45 \s ubsection{Lisp from Java}76 \section{Lisp from Java} 46 77 47 78 Manipulation of the Lisp API is currently lacking a stable interface, … … 60 91 \end{itemize} 61 92 62 \subs ubsection{Lisp FFI}93 \subsection{Lisp FFI} 63 94 64 95 FFI stands for "Foreign Function Interface" which is the phase which … … 69 100 needs to be "Interfaced". 70 101 71 \subs ubsection{Calling Lisp from Java}102 \subsection{Calling Lisp from Java} 72 103 73 104 Note: As the entire ABCL Lisp system resides in the org.armedbear.lisp … … 76 107 statement would be 77 108 78 \lstset{language=Java} 79 \begin{lstlisting} 109 \begin{listing-java} 80 110 import org.armedbear.lisp.*; 81 \end{l stliting}111 \end{listing-java} 82 112 83 113 to potentially import all the JVM symbol from the `org.armedbear.lisp' … … 87 117 started by calling the static method `Interpreter.createInstance()`. 88 118 89 \begin{ code}[java]119 \begin{listing-java} 90 120 Interpreter interpreter = Interpreter.createInstance(); 91 \end{ code}121 \end{listing-java} 92 122 93 123 If this method has already been invoked in the lifetime of the current … … 103 133 \end{code} 104 134 105 106 135 The Lisp \code{eval} primitive may be simply passed strings for evaluation, 107 136 as follows 108 137 109 \begin{ code}[java]138 \begin{listing-java} 110 139 String line = "(load \"file.lisp\")"; 111 140 LispObject result = interpreter.eval(line); 112 \end{ code}141 \end{listing-java} 113 142 114 143 Notice that all possible return values from an arbitrary Lisp … … 119 148 (c.f. [Introspecting a LispObject]) 120 149 121 Using ``EVAL'' involves the Lisp interpreter. Lisp functions may be122 directly invoked by Java method calls as follows. One simply locates 123 the package containing the symbol, then obtains a reference to the 124 symbol, and then invokes the `execute()` method with the desired 125 parameters.126 127 \begin{ code}[java]150 Using \code{eval} involves the Lisp interpreter. Lisp functions may 151 be directly invoked by Java method calls as follows. One simply 152 locates the package containing the symbol, then obtains a reference to 153 the symbol, and then invokes the \code{execute()} method with the 154 desired parameters. 155 156 \begin{listing-java} 128 157 interpreter.eval("(defun foo (msg) (format nil \"You told me '~A'~%\" msg))"); 129 158 Package pkg = Packages.findPackage("CL-USER"); … … 134 163 // How to get the "naked string value"? 135 164 System.out.println("The result was " + result.writeToString()); 136 \end{ code}165 \end{listing-java} 137 166 138 167 If one is calling an primitive function in the CL package the syntax … … 141 170 tell if a `LispObject` contains a reference to a symbol. 142 171 143 \begin{ code}[java]172 \begin{listing-java} 144 173 boolean nullp(LispObject object) { 145 174 LispObject result = Primitives.NULL.execute(object); … … 149 178 return true; 150 179 } 151 \end{ code}152 153 \ paragraph{Introspecting a LispObject}180 \end{listing-java} 181 182 \subsubsection{Introspecting a LispObject} 154 183 \label{topic:Introspecting a LispObject} 155 184 … … 158 187 into semantics that Java can meaniningfully deal with. 159 188 160 \ paragraph{LispObject as \code{boolean}}189 \subsubsection{LispObject as \code{boolean}} 161 190 162 191 If the LispObject a generalized boolean values, one can use 163 192 \code{getBooleanValue()} to convert to Java: 164 193 165 \begin{ code}[java]194 \begin{listing-java} 166 195 LispObject object = Symbol.NIL; 167 196 boolean javaValue = object.getBooleanValue(); 168 \end{ code}197 \end{listing-java} 169 198 170 199 Although since in Lisp, any value other than NIL means "true", the 171 200 use of Java equality it quite a bit easier and more optimal: 172 201 173 \begin{ code}[java]202 \begin{listing-java} 174 203 boolean javaValue = (object != Symbol.NIL); 175 \end{ code}204 \end{listing-java} 176 205 177 206 \paragraph{LispObject is a list} … … 181 210 iteration. 182 211 183 \begin{ code}[java]212 \begin{listing-java} 184 213 LispObject result = interpreter.eval("'(1 2 4 5)"); 185 214 if (result instanceof Cons) { … … 187 216 ... 188 217 } 189 \end{ code}218 \end{listing-java} 190 219 191 220 A more Lispy way to iterated down a list is to use the `cdr()` access 192 221 function just as like one would traverse a list in Lisp:; 193 222 194 \begin{ code}[java]223 \begin{listing-java} 195 224 LispObject result = interpreter.eval("'(1 2 4 5)"); 196 225 while (result != Symbol.NIL) { … … 198 227 result = result.cdr(); 199 228 } 200 \end{ code}201 202 203 \s ubsection{JAVA}229 \end{listing-java} 230 231 232 \section{Java} 204 233 205 234 % include autogen docs for the JAVA package. 206 207 \section{ANSI Common Lisp Conformance} 208 209 ABCL is currently a non-conforming ANSI Common Lisp implementation due 210 to the following (known) issues: 211 212 \begin{itemize} 213 \item Lack of long form of DEFINE-METHOD-COMBINATION 214 \item Missing statement of conformance in accompanying documentation 215 \item Incomplete MOP 216 % TODO go through AMOP with symbols, starting by looking for 217 % matching function signature. 218 % XXX is this really blocking ANSI conformance? Answer: we have 219 % to start with such a ``census'' to determine what we have. 220 \end{itemize} 221 222 ABCL aims to be be a fully conforming ANSI Common Lisp 223 implementation. Any other behavior should be reported as a bug. 235 \include{java} 236 237 \section{Multithreading} 238 239 % TODO document the THREADS package. 240 \include{threads} 224 241 225 242 \section{Extensions} … … 233 250 \include{extensions} 234 251 235 \ subsection{Beyond ANSI}252 \chapter{Beyond ANSI} 236 253 237 254 Naturally, in striving to be a useful contemporary Common Lisp … … 240 257 in working with the hosting JVM. 241 258 242 \s ubsubsection{Extensions to CLOS}259 \section{Extensions to CLOS} 243 260 244 261 There is an additional syntax for specializing the parameter of a … … 251 268 object 252 269 253 \begin{code}[lisp] 254 (defmethod print-object ((coll (java:jclass "java.util.Collection")) stream) 255 \ldots 256 \end{code} 270 \begin{listing-lisp} 271 (defmethod print-object ((coll (java:jclass "java.util.Collection")) 272 stream) 273 ;;; ... 274 ) 275 \end{listing-lisp} 257 276 258 277 If the class had been loaded via a classloader other than the original … … 260 279 classloader as an optional third argument. 261 280 262 \begin{code}[lisp] 263 (defmethod print-object ((device-id (java:jclass "dto.nbi.service.hdm.alcatel.com.nNBIDeviceID" 264 (\#"getBaseLoader" cl-user::*classpath-manager*))) 265 \ldots 266 \end{code} 267 268 \subsubsection{Extensions to the Reader} 281 \begin{listing-lisp} 282 283 (defparameter *other-classloader* 284 (jcall "getBaseLoader" cl-user::*classpath-manager*)) 285 286 (defmethod print-object ((device-id (java:jclass "dto.nbi.service.hdm.alcatel.com.NBIDeviceID" *other-classloader*)) 287 stream) 288 ;;; ... 289 ) 290 \end{listing-lisp} 291 292 \section{Extensions to the Reader} 269 293 270 294 We implement a special hexadecimal escape sequence for specifying … … 279 303 code is greater than 0x00ff. 280 304 281 \section{Multithreading} 282 283 % TODO document the THREADS package. 284 \include{threads} 285 286 \section{History} 305 \chapter{History} 287 306 288 307 ABCL was originally the extension language for the J editor, which was -
trunk/abcl/doc/manual/java.tex
r13437 r13438 1 1 \begin{verbatim} 2 2 3 %JGET-PROPERTY-VALUE 3 4 Function: Gets a JavaBeans property on JAVA-OBJECT. 5 4 6 %JSET-PROPERTY-VALUE 5 7 Function: Sets a JavaBean property on JAVA-OBJECT. 6 *JAVA-OBJECT-TO-STRING-LENGTH* 7 Variable: Length to truncate toString() PRINT-OBJECT output for an otherwise unspecialized JAVA-OBJECT. Can be set to NIL to indicate no limit. 8 9 *JAVA-OBJECT-TO-STRING-LENGTH* 10 Variable: Length to truncate toString() 11 PRINT-OBJECT output for an otherwise unspecialized JAVA-OBJECT. Can 12 be set to NIL to indicate no limit. 13 8 14 ADD-TO-CLASSPATH 9 15 Function: (not documented) 16 10 17 CHAIN 11 18 Function: (not documented) 19 12 20 DESCRIBE-JAVA-OBJECT 13 21 Function: (not documented) 22 14 23 DUMP-CLASSPATH 15 24 Function: (not documented) 25 16 26 ENSURE-JAVA-CLASS 17 27 Function: (not documented) 28 18 29 ENSURE-JAVA-OBJECT 19 30 Function: Ensures OBJ is wrapped in a JAVA-OBJECT, wrapping it if necessary. 31 20 32 GET-DEFAULT-CLASSLOADER 21 33 Function: (not documented) 34 22 35 JARRAY-COMPONENT-TYPE 23 36 Function: Returns the component type of the array type ATYPE 37 24 38 JARRAY-LENGTH 25 39 Function: (not documented) 40 26 41 JARRAY-REF 27 Function: Dereferences the Java array JAVA-ARRAY using the given INDICIES, coercing the result into a Lisp object, if possible. 42 Function: Dereferences the Java array JAVA-ARRAY using the given 43 INDICIES, coercing the result into a Lisp object, if possible. 44 28 45 JARRAY-REF-RAW 29 Function: Dereference the Java array JAVA-ARRAY using the given INDICIES. Does not attempt to coerce the result into a Lisp object. 46 Function: Dereference the Java array JAVA-ARRAY using the given 47 INDICIES. Does not attempt to coerce the result into a Lisp object. 48 30 49 JARRAY-SET 31 50 Function: Stores NEW-VALUE at the given index in JAVA-ARRAY. 51 32 52 JAVA-CLASS 33 53 Class: (not documented) 54 34 55 JAVA-EXCEPTION 35 56 Class: (not documented) 57 36 58 JAVA-EXCEPTION-CAUSE 37 59 Function: Returns the cause of JAVA-EXCEPTION. (The cause is the Java Throwable 60 38 61 JAVA-OBJECT 39 62 Class: (not documented) 63 40 64 JAVA-OBJECT-P 41 65 Function: Returns T if OBJECT is a JAVA-OBJECT. 66 42 67 JCALL 43 Function: Invokes the Java method METHOD-REF on INSTANCE with arguments ARGS, coercing the result into a Lisp object, if possible. 68 Function: Invokes the Java method METHOD-REF on INSTANCE with 69 arguments ARGS, coercing the result into a Lisp object, if possible. 70 44 71 JCALL-RAW 45 Function: Invokes the Java method METHOD-REF on INSTANCE with arguments ARGS. Does not attempt to coerce the result into a Lisp object. 72 Function: Invokes the Java method METHOD-REF on INSTANCE with 73 arguments ARGS. Does not attempt to coerce the result into a Lisp 74 object. 75 46 76 JCLASS 47 Function: Returns a reference to the Java class designated by NAME-OR-CLASS-REF. If the CLASS-LOADER parameter is passed, the class is resolved with respect to the given ClassLoader. 77 Function: Returns a reference to the Java class designated by 78 NAME-OR-CLASS-REF. If the CLASS-LOADER parameter is passed, the class 79 is resolved with respect to the given ClassLoader. 80 48 81 JCLASS-ARRAY-P 49 82 Function: Returns T if CLASS is an array class 83 50 84 JCLASS-CONSTRUCTORS 51 85 Function: Returns a vector of constructors for CLASS 86 52 87 JCLASS-FIELD 53 88 Function: Returns the field named FIELD-NAME of CLASS 89 54 90 JCLASS-FIELDS 55 Function: Returns a vector of all (or just the declared/public, if DECLARED/PUBLIC is true) fields of CLASS 91 Function: Returns a vector of all (or just the declared/public, if 92 DECLARED/PUBLIC is true) fields of CLASS 93 56 94 JCLASS-INTERFACE-P 57 95 Function: Returns T if CLASS is an interface 96 58 97 JCLASS-INTERFACES 59 98 Function: Returns the vector of interfaces of CLASS 99 60 100 JCLASS-METHODS 61 Function: Return a vector of all (or just the declared/public, if DECLARED/PUBLIC is true) methods of CLASS 101 Function: Return a vector of all (or just the declared/public, if 102 DECLARED/PUBLIC is true) methods of CLASS 103 62 104 JCLASS-NAME 63 105 Function: When called with one argument, returns the name of the Java class 106 64 107 JCLASS-OF 65 108 Function: (not documented) 109 66 110 JCLASS-SUPERCLASS 67 111 Function: Returns the superclass of CLASS, or NIL if it hasn't got one 112 68 113 JCLASS-SUPERCLASS-P 69 114 Function: Returns T if CLASS-1 is a superclass or interface of CLASS-2 115 70 116 JCOERCE 71 Function: Attempts to coerce OBJECT into a JavaObject of class INTENDED-CLASS. Raises a TYPE-ERROR if no conversion is possible. 117 Function: Attempts to coerce OBJECT into a JavaObject of class 118 INTENDED-CLASS. Raises a TYPE-ERROR if no conversion is possible. 119 72 120 JCONSTRUCTOR 73 Function: Returns a reference to the Java constructor of CLASS-REF with the given PARAMETER-CLASS-REFS. 121 Function: Returns a reference to the Java constructor of CLASS-REF 122 with the given PARAMETER-CLASS-REFS. 123 74 124 JCONSTRUCTOR-PARAMS 75 125 Function: Returns a vector of parameter types (Java classes) for CONSTRUCTOR 126 76 127 JEQUAL 77 128 Function: Compares obj1 with obj2 using java.lang.Object.equals() 129 78 130 JFIELD 79 131 Function: Retrieves or modifies a field in a Java class or instance. 132 80 133 JFIELD-NAME 81 134 Function: Returns the name of FIELD as a Lisp string 135 82 136 JFIELD-RAW 83 137 Function: Retrieves or modifies a field in a Java class or instance. Does not 138 84 139 JFIELD-TYPE 85 140 Function: Returns the type (Java class) of FIELD 141 86 142 JINSTANCE-OF-P 87 143 Function: OBJ is an instance of CLASS (or one of its subclasses) 144 88 145 JINTERFACE-IMPLEMENTATION 89 146 Function: Creates and returns an implementation of a Java interface with 147 90 148 JMAKE-INVOCATION-HANDLER 91 149 Function: (not documented) 150 92 151 JMAKE-PROXY 93 152 Function: (not documented) 153 94 154 JMEMBER-PROTECTED-P 95 155 Function: MEMBER is a protected member of its declaring class 156 96 157 JMEMBER-PUBLIC-P 97 158 Function: MEMBER is a public member of its declaring class 159 98 160 JMEMBER-STATIC-P 99 161 Function: MEMBER is a static member of its declaring class 162 100 163 JMETHOD 101 Function: Returns a reference to the Java method METHOD-NAME of CLASS-REF with the given PARAMETER-CLASS-REFS. 164 Function: Returns a reference to the Java method METHOD-NAME of 165 CLASS-REF with the given PARAMETER-CLASS-REFS. 166 102 167 JMETHOD-LET 103 168 Function: (not documented) 169 104 170 JMETHOD-NAME 105 171 Function: Returns the name of METHOD as a Lisp string 172 106 173 JMETHOD-PARAMS 107 174 Function: Returns a vector of parameter types (Java classes) for METHOD 175 108 176 JMETHOD-RETURN-TYPE 109 177 Function: Returns the result type (Java class) of the METHOD 178 110 179 JNEW 111 180 Function: Invokes the Java constructor CONSTRUCTOR with the arguments ARGS. 181 112 182 JNEW-ARRAY 113 183 Function: Creates a new Java array of type ELEMENT-TYPE, with the given DIMENSIONS. 184 114 185 JNEW-ARRAY-FROM-ARRAY 115 186 Function: Returns a new Java array with base type ELEMENT-TYPE (a string or a class-ref) 187 116 188 JNEW-ARRAY-FROM-LIST 117 189 Function: (not documented) 190 118 191 JNEW-RUNTIME-CLASS 119 192 Function: (not documented) 193 120 194 JNULL-REF-P 121 195 Function: Returns a non-NIL value when the JAVA-OBJECT `object` is `null`, 196 122 197 JOBJECT-CLASS 123 198 Function: Returns the Java class that OBJ belongs to 199 124 200 JOBJECT-LISP-VALUE 125 201 Function: Attempts to coerce JAVA-OBJECT into a Lisp object. 202 126 203 JPROPERTY-VALUE 127 204 Function: (not documented) 205 128 206 JREDEFINE-METHOD 129 207 Function: (not documented) 208 130 209 JREGISTER-HANDLER 131 210 Function: (not documented) 211 132 212 JRESOLVE-METHOD 133 Function: Finds the most specific Java method METHOD-NAME on INSTANCE applicable to arguments ARGS. Returns NIL if no suitable method is found. The algorithm used for resolution is the same used by JCALL when it is called with a string as the first parameter (METHOD-REF). 213 Function: Finds the most specific Java method METHOD-NAME on 214 INSTANCE applicable to arguments ARGS. Returns NIL if no suitable 215 method is found. The algorithm used for resolution is the same used 216 by JCALL when it is called with a string as the first parameter 217 (METHOD-REF). 218 134 219 JRUN-EXCEPTION-PROTECTED 135 Function: Invokes the function CLOSURE and returns the result. Signals an error if stack or heap exhaustion occurs. 220 Function: Invokes the function CLOSURE and returns the result. 221 Signals an error if stack or heap exhaustion occurs. 222 136 223 JRUNTIME-CLASS-EXISTS-P 137 224 Function: (not documented) 225 138 226 JSTATIC 139 227 Function: Invokes the static method METHOD on class CLASS with ARGS. 228 140 229 JSTATIC-RAW 141 Function: Invokes the static method METHOD on class CLASS with ARGS. Does not attempt to coerce the arguments or result into a Lisp object. 230 Function: Invokes the static method METHOD on class CLASS with 231 ARGS. Does not attempt to coerce the arguments or result into a Lisp 232 object. 233 142 234 MAKE-CLASSLOADER 143 235 Function: (not documented) 236 144 237 MAKE-IMMEDIATE-OBJECT 145 238 Function: Attempts to coerce a given Lisp object into a java-object of the 239 146 240 REGISTER-JAVA-EXCEPTION 147 Function: Registers the Java Throwable named by the symbol EXCEPTION-NAME as the condition designated by CONDITION-SYMBOL. Returns T if successful, NIL if not. 241 Function: Registers the Java Throwable named by the symbol 242 EXCEPTION-NAME as the condition designated by CONDITION-SYMBOL. 243 Returns T if successful, NIL if not. 244 148 245 UNREGISTER-JAVA-EXCEPTION 149 246 Function: Unregisters the Java Throwable EXCEPTION-NAME previously registered by REGISTER-JAVA-EXCEPTION. 247 150 248 \end{verbatim}
Note: See TracChangeset
for help on using the changeset viewer.