diff options
40 files changed, 586 insertions, 707 deletions
@@ -299,9 +299,8 @@ Guile Documentation ================================================== If you've never used Scheme before, then the Guile Tutorial (guile-tut.info) is a good starting point. The Guile Reference Manual -(guile.info) is the primary documentation for Guile. The Goops object -system is documented separately (goops.info). A copy of the R5RS -Scheme specification is included too (r5rs.info). +(guile.info) is the primary documentation for Guile. A copy of the +R5RS Scheme specification is included too (r5rs.info). Info format versions of this documentation are installed as part of the normal build process. The texinfo sources are under the doc diff --git a/configure.ac b/configure.ac index 7331ef264..8f420b555 100644 --- a/configure.ac +++ b/configure.ac @@ -1518,7 +1518,6 @@ AC_CONFIG_FILES([ lib/Makefile benchmark-suite/Makefile doc/Makefile - doc/goops/Makefile doc/r5rs/Makefile doc/ref/Makefile doc/tutorial/Makefile @@ -1555,6 +1554,7 @@ AC_CONFIG_FILES([test-suite/standalone/test-use-srfi], [chmod +x test-suite/standalone/test-use-srfi]) AC_CONFIG_FILES([test-suite/standalone/test-fast-slot-ref], [chmod +x test-suite/standalone/test-fast-slot-ref]) +AC_CONFIG_FILES([doc/ref/effective-version.texi]) AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am index 0a6b14ed5..06f55a7e3 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -21,7 +21,7 @@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = ref tutorial goops r5rs +SUBDIRS = ref tutorial r5rs dist_man1_MANS = guile.1 diff --git a/doc/README b/doc/README index 3ecd329b4..18862a6b8 100644 --- a/doc/README +++ b/doc/README @@ -8,10 +8,6 @@ The documentation consists of the following manuals. - The Guile Reference Manual (guile.texi) contains (or is intended to contain) reference documentation on all aspects of Guile. -- The GOOPS Manual (goops.texi) contains both tutorial-style and - reference documentation for using GOOPS, Guile's Object Oriented - Programming System. - - The Revised^5 Report on the Algorithmic Language Scheme (r5rs.texi). Please be aware that this is all very much work in progress (apart diff --git a/doc/goops/Makefile.am b/doc/goops/Makefile.am deleted file mode 100644 index 49bfb29b9..000000000 --- a/doc/goops/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -## Process this file with Automake to create Makefile.in -## -## Copyright (C) 1998, 2004, 2006, 2008 Free Software Foundation, Inc. -## -## This file is part of GUILE. -## -## GUILE is free software; you can redistribute it and/or modify it -## under the terms of the GNU Lesser General Public License as -## published by the Free Software Foundation; either version 3, or -## (at your option) any later version. -## -## GUILE is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with GUILE; see the file COPYING.LESSER. If not, -## write to the Free Software Foundation, Inc., 51 Franklin Street, -## Fifth Floor, Boston, MA 02110-1301 USA - -AUTOMAKE_OPTIONS = gnu - -info_TEXINFOS = goops.texi - -goops_TEXINFOS = goops-tutorial.texi \ - hierarchy.eps hierarchy.png hierarchy.txt hierarchy.pdf - -EXTRA_DIST = ChangeLog-2008 diff --git a/doc/ref/.gitignore b/doc/ref/.gitignore index fc69e3188..c76e2e4af 100644 --- a/doc/ref/.gitignore +++ b/doc/ref/.gitignore @@ -1,2 +1,3 @@ autoconf-macros.texi lib-version.texi +effective-version.texi diff --git a/doc/goops/ChangeLog-2008 b/doc/ref/ChangeLog-goops-2008 index a5a637d7b..a5a637d7b 100644 --- a/doc/goops/ChangeLog-2008 +++ b/doc/ref/ChangeLog-goops-2008 diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am index abf42edfe..2f218a565 100644 --- a/doc/ref/Makefile.am +++ b/doc/ref/Makefile.am @@ -78,11 +78,20 @@ guile_TEXINFOS = preface.texi \ libguile-linking.texi \ libguile-extensions.texi \ api-init.texi \ - mod-getopt-long.texi + mod-getopt-long.texi \ + goops.texi \ + goops-tutorial.texi \ + effective-version.texi ETAGS_ARGS = $(info_TEXINFOS) $(guile_TEXINFOS) -EXTRA_DIST = ChangeLog-2008 +PICTURES = hierarchy.eps \ + hierarchy.pdf \ + hierarchy.png \ + hierarchy.txt \ + mop.text + +EXTRA_DIST = ChangeLog-2008 $(PICTURES) include $(top_srcdir)/am/pre-inst-guile diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi index 7eccb8690..059390bb8 100644 --- a/doc/ref/api-compound.texi +++ b/doc/ref/api-compound.texi @@ -1344,9 +1344,9 @@ otherwise. @deftypefn {C Function} SCM scm_take_u8vector (const scm_t_uint8 *data, size_t len) @deftypefnx {C Function} SCM scm_take_s8vector (const scm_t_int8 *data, size_t len) @deftypefnx {C Function} SCM scm_take_u16vector (const scm_t_uint16 *data, size_t len) -@deftypefnx {C Function} SCM scm_take_s168vector (const scm_t_int16 *data, size_t len) +@deftypefnx {C Function} SCM scm_take_s16vector (const scm_t_int16 *data, size_t len) @deftypefnx {C Function} SCM scm_take_u32vector (const scm_t_uint32 *data, size_t len) -@deftypefnx {C Function} SCM scm_take_s328vector (const scm_t_int32 *data, size_t len) +@deftypefnx {C Function} SCM scm_take_s32vector (const scm_t_int32 *data, size_t len) @deftypefnx {C Function} SCM scm_take_u64vector (const scm_t_uint64 *data, size_t len) @deftypefnx {C Function} SCM scm_take_s64vector (const scm_t_int64 *data, size_t len) @deftypefnx {C Function} SCM scm_take_f32vector (const float *data, size_t len) @@ -2001,13 +2001,24 @@ enclosed array is unspecified. For example, @lisp -(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) +(enclose-array '#3(((a b c) + (d e f)) + ((1 2 3) + (4 5 6))) + 1) @result{} -#<enclosed-array (#1(a d) #1(b e) #1(c f)) (#1(1 4) #1(2 5) #1(3 6))> - -(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) +#<enclosed-array (#1(a d) #1(b e) #1(c f)) + (#1(1 4) #1(2 5) #1(3 6))> + +(enclose-array '#3(((a b c) + (d e f)) + ((1 2 3) + (4 5 6))) + 1 0) @result{} -#<enclosed-array #2((a 1) (d 4)) #2((b 2) (e 5)) #2((c 3) (f 6))> +#<enclosed-array #2((a 1) (d 4)) + #2((b 2) (e 5)) + #2((c 3) (f 6))> @end lisp @end deffn @@ -3083,8 +3094,10 @@ which can be changed. (color ball) (owner ball))) ball-color)) -(define (color ball) (struct-ref (struct-vtable ball) vtable-offset-user)) -(define (owner ball) (struct-ref ball 0)) +(define (color ball) + (struct-ref (struct-vtable ball) vtable-offset-user)) +(define (owner ball) + (struct-ref ball 0)) (define red (make-ball-type 'red)) (define green (make-ball-type 'green)) @@ -3460,7 +3473,8 @@ whole is not a proper list: (assoc "mary" '((1 . 2) ("key" . "door") . "open sesame")) @result{} ERROR: In procedure assoc in expression (assoc "mary" (quote #)): -ERROR: Wrong type argument in position 2 (expecting association list): ((1 . 2) ("key" . "door") . "open sesame") +ERROR: Wrong type argument in position 2 (expecting + association list): ((1 . 2) ("key" . "door") . "open sesame") (sloppy-assoc "mary" '((1 . 2) ("key" . "door") . "open sesame")) @result{} @@ -3474,7 +3488,8 @@ Secondly, if one of the entries in the specified alist is not a pair: (assoc 2 '((1 . 1) 2 (3 . 9))) @result{} ERROR: In procedure assoc in expression (assoc 2 (quote #)): -ERROR: Wrong type argument in position 2 (expecting association list): ((1 . 1) 2 (3 . 9)) +ERROR: Wrong type argument in position 2 (expecting + association list): ((1 . 1) 2 (3 . 9)) (sloppy-assoc 2 '((1 . 1) 2 (3 . 9))) @result{} diff --git a/doc/ref/api-control.texi b/doc/ref/api-control.texi index ed6411f29..e7614d136 100644 --- a/doc/ref/api-control.texi +++ b/doc/ref/api-control.texi @@ -22,6 +22,7 @@ flow of Scheme affects C code. * Error Reporting:: Procedures for signaling errors. * Dynamic Wind:: Dealing with non-local entrance/exit. * Handling Errors:: How to handle errors in C code. +* Continuation Barriers:: Protection from non-local control flow. @end menu @node begin @@ -1501,6 +1502,33 @@ which is the name of the procedure incorrectly invoked. @end deftypefn +@node Continuation Barriers +@subsection Continuation Barriers + +The non-local flow of control caused by continuations might sometimes +not be wanted. You can use @code{with-continuation-barrier} etc to +errect fences that continuations can not pass. + +@deffn {Scheme Procedure} with-continuation-barrier proc +@deffnx {C Function} scm_with_continuation_barrier (proc) +Call @var{proc} and return its result. Do not allow the invocation of +continuations that would leave or enter the dynamic extent of the call +to @code{with-continuation-barrier}. Such an attempt causes an error +to be signaled. + +Throws (such as errors) that are not caught from within @var{proc} are +caught by @code{with-continuation-barrier}. In that case, a short +message is printed to the current error port and @code{#f} is returned. + +Thus, @code{with-continuation-barrier} returns exactly once. +@end deffn + +@deftypefn {C Function} {void *} scm_c_with_continuation_barrier (void *(*func) (void *), void *data) +Like @code{scm_with_continuation_barrier} but call @var{func} on +@var{data}. When an error is caught, @code{NULL} is returned. +@end deftypefn + + @c Local Variables: @c TeX-master: "guile.texi" @c End: diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi index 6e1a67ae1..0fd4ee1cf 100755 --- a/doc/ref/api-data.texi +++ b/doc/ref/api-data.texi @@ -3477,9 +3477,9 @@ allocated string. @deffnx {C Function} scm_string_concatenate_reverse (ls, final_string, end) Without optional arguments, this procedure is equivalent to -@smalllisp +@lisp (string-concatenate (reverse ls)) -@end smalllisp +@end lisp If the optional argument @var{final_string} is specified, it is consed onto the beginning to @var{ls} before performing the @@ -3535,11 +3535,12 @@ For example, to change characters to alternately upper and lower case, @example (define str (string-copy "studly")) -(string-for-each-index (lambda (i) - (string-set! str i - ((if (even? i) char-upcase char-downcase) - (string-ref str i)))) - str) +(string-for-each-index + (lambda (i) + (string-set! str i + ((if (even? i) char-upcase char-downcase) + (string-ref str i)))) + str) str @result{} "StUdLy" @end example @end deffn @@ -4447,7 +4448,8 @@ Or matching a @sc{yyyymmdd} format date such as @samp{20020828} and re-ordering and hyphenating the fields. @lisp -(define date-regex "([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])") +(define date-regex + "([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])") (define s "Date 20020429 12am.") (regexp-substitute #f (string-match date-regex s) 'pre 2 "-" 3 "-" 1 'post " (" 0 ")") @@ -4507,7 +4509,8 @@ example the following is the date example from @code{string-match} call. @lisp -(define date-regex "([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])") +(define date-regex + "([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])") (define s "Date 20020429 12am.") (regexp-substitute/global #f date-regex s 'pre 2 "-" 3 "-" 1 'post " (" 0 ")") @@ -5502,7 +5505,7 @@ the @code{read-set!} procedure documented in @ref{User level options interfaces} and @ref{Reader options}. Note that the @code{prefix} and @code{postfix} syntax are mutually exclusive. -@smalllisp +@lisp (read-set! keywords 'prefix) #:type @@ -5534,7 +5537,7 @@ type: ERROR: In expression :type: ERROR: Unbound variable: :type ABORT: (unbound-variable) -@end smalllisp +@end lisp @node Keyword Procedures @subsubsection Keyword Procedures diff --git a/doc/ref/api-debug.texi b/doc/ref/api-debug.texi index 78863665d..28dc73233 100644 --- a/doc/ref/api-debug.texi +++ b/doc/ref/api-debug.texi @@ -1732,16 +1732,16 @@ Frame 2 at matrix.scm:8:3 [mkmatrix] debug> next Frame 3 at matrix.scm:4:3 - (let ((x 1)) (quote this-is-a-matric)) + (let ((x 1)) (quote hi!)) debug> info frame Stack frame: 3 This frame is an evaluation. The expression being evaluated is: matrix.scm:4:3: - (let ((x 1)) (quote this-is-a-matric)) + (let ((x 1)) (quote hi!)) debug> next Frame 3 at matrix.scm:5:21 - (quote this-is-a-matric) + (quote hi!) debug> bt In unknown file: ?: 0* [primitive-eval (do-main 4)] @@ -1750,9 +1750,9 @@ In standard input: In matrix.scm: 8: 2 [mkmatrix] ... - 5: 3 (quote this-is-a-matric) + 5: 3 (quote hi!) debug> quit -this-is-a-matric +hi! guile> @end lisp @@ -1813,7 +1813,7 @@ guile> (do-main 4) | 5: (memq sym bindings) | 5: [memq let (debug)] | 5: =>#f -| 2: (letrec ((yy 23)) (let ((x 1)) (quote this-is-a-matric))) +| 2: (letrec ((yy 23)) (let ((x 1)) (quote hi!))) | 3: [#<procedure #f (a sym definep)> #<autoload # b7c93870> let #f] | 3: [#<procedure #f (a sym definep)> #<autoload # b7c93870> let #f] | 4: (and (memq sym bindings) (let ...)) @@ -1832,7 +1832,7 @@ guile> (do-main 4) | 5: (memq sym bindings) | 5: [memq let (debug)] | 5: =>#f -| 2: (let ((x 1)) (quote this-is-a-matric)) +| 2: (let ((x 1)) (quote hi!)) | 3: [#<procedure #f (a sym definep)> #<autoload # b7c93870> let #f] | 3: [#<procedure #f (a sym definep)> #<autoload # b7c93870> let #f] | 4: (and (memq sym bindings) (let ...)) @@ -1841,15 +1841,15 @@ guile> (do-main 4) | 5: =>#f | 2: [let (let # #) (# # #)] | 2: [let (let # #) (# # #)] -| 2: =>(#@@let* (x 1) #@@let (quote this-is-a-matric)) -this-is-a-matric +| 2: =>(#@@let* (x 1) #@@let (quote hi!)) +hi! guile> (do-main 4) | 2: [mkmatrix] -| 2: (letrec ((yy 23)) (let* ((x 1)) (quote this-is-a-matric))) -| 2: (let* ((x 1)) (quote this-is-a-matric)) -| 2: (quote this-is-a-matric) -| 2: =>this-is-a-matric -this-is-a-matric +| 2: (letrec ((yy 23)) (let* ((x 1)) (quote hi!))) +| 2: (let* ((x 1)) (quote hi!)) +| 2: (quote hi!) +| 2: =>hi! +hi! guile> @end lisp @@ -1881,11 +1881,11 @@ each trace line instead of the stack depth. guile> (set-trace-layout "|~16@@a: ~a\n" trace/source trace/info) guile> (do-main 4) | matrix.scm:7:2: [mkmatrix] -| : (letrec ((yy 23)) (let* ((x 1)) (quote this-is-a-matric))) -| matrix.scm:3:2: (let* ((x 1)) (quote this-is-a-matric)) -| matrix.scm:4:4: (quote this-is-a-matric) -| matrix.scm:4:4: =>this-is-a-matric -this-is-a-matric +| : (letrec ((yy 23)) (let* ((x 1)) (quote hi!))) +| matrix.scm:3:2: (let* ((x 1)) (quote hi!)) +| matrix.scm:4:4: (quote hi!) +| matrix.scm:4:4: =>hi! +hi! guile> @end lisp diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi index b0b57412a..96cd147f3 100644 --- a/doc/ref/api-io.texi +++ b/doc/ref/api-io.texi @@ -424,9 +424,9 @@ the current size, but this is not mandatory in the POSIX standard. The delimited-I/O module can be accessed with: -@smalllisp +@lisp (use-modules (ice-9 rdelim)) -@end smalllisp +@end lisp It can be used to read or write lines of text, or read text delimited by a specified set of characters. It's similar to the @code{(scsh rdelim)} @@ -536,9 +536,9 @@ delimiter may be either a newline or the @var{eof-object}; if The Block-string-I/O module can be accessed with: -@smalllisp +@lisp (use-modules (ice-9 rw)) -@end smalllisp +@end lisp It currently contains procedures that help to implement the @code{(scsh rw)} module in guile-scsh. @@ -795,17 +795,17 @@ current interfaces. @rnindex open-input-file @deffn {Scheme Procedure} open-input-file filename Open @var{filename} for input. Equivalent to -@smalllisp +@lisp (open-file @var{filename} "r") -@end smalllisp +@end lisp @end deffn @rnindex open-output-file @deffn {Scheme Procedure} open-output-file filename Open @var{filename} for output. Equivalent to -@smalllisp +@lisp (open-file @var{filename} "w") -@end smalllisp +@end lisp @end deffn @deffn {Scheme Procedure} call-with-input-file filename proc diff --git a/doc/ref/api-modules.texi b/doc/ref/api-modules.texi index 9aeb08a44..02e260d7e 100644 --- a/doc/ref/api-modules.texi +++ b/doc/ref/api-modules.texi @@ -60,15 +60,15 @@ Library files in SLIB @emph{provide} a feature, and when user programs For example, the file @file{random.scm} in the SLIB package contains the line -@smalllisp +@lisp (provide 'random) -@end smalllisp +@end lisp so to use its procedures, a user would type -@smalllisp +@lisp (require 'random) -@end smalllisp +@end lisp and they would magically become available, @emph{but still have the same names!} So this method is nice, but not as good as a full-featured @@ -99,9 +99,9 @@ i.e., passed as the second argument to @code{eval}. Note: the following two procedures are available only when the @code{(ice-9 r5rs)} module is loaded: -@smalllisp +@lisp (use-modules (ice-9 r5rs)) -@end smalllisp +@end lisp @deffn {Scheme Procedure} scheme-report-environment version @deffnx {Scheme Procedure} null-environment version @@ -224,9 +224,9 @@ An @dfn{interface specification} has one of two forms. The first variation is simply to name the module, in which case its public interface is the one accessed. For example: -@smalllisp +@lisp (use-modules (ice-9 popen)) -@end smalllisp +@end lisp Here, the interface specification is @code{(ice-9 popen)}, and the result is that the current module now has access to @code{open-pipe}, @@ -241,11 +241,11 @@ module to be accessed, but also selects bindings from it and renames them to suit the current module's needs. For example: @cindex binding renamer -@smalllisp +@lisp (use-modules ((ice-9 popen) - :select ((open-pipe . pipe-open) close-pipe) - :renamer (symbol-prefix-proc 'unixy:))) -@end smalllisp + #:select ((open-pipe . pipe-open) close-pipe) + #:renamer (symbol-prefix-proc 'unixy:))) +@end lisp Here, the interface specification is more complex than before, and the result is that a custom interface with only two bindings is created and @@ -270,10 +270,10 @@ You can also directly refer to bindings in a module by using the open-pipe)}. Thus an alternative to the complete @code{use-modules} statement would be -@smalllisp +@lisp (define unixy:pipe-open (@@ (ice-9 popen) open-pipe)) (define unixy:close-pipe (@@ (ice-9 popen) close-pipe)) -@end smalllisp +@end lisp There is also @code{@@@@}, which can be used like @code{@@}, but does not check whether the variable that is being accessed is actually @@ -307,9 +307,9 @@ whose public interface is found and used. @var{spec} can also be of the form: @cindex binding renamer -@smalllisp +@lisp (MODULE-NAME [:select SELECTION] [:renamer RENAMER]) -@end smalllisp +@end lisp in which case a custom interface is newly created and used. @var{module-name} is a list of symbols, as above; @var{selection} is a @@ -373,9 +373,9 @@ by using @code{define-public} or @code{export} (both documented below). @var{module-name} is of the form @code{(hierarchy file)}. One example of this is -@smalllisp +@lisp (define-module (ice-9 popen)) -@end smalllisp +@end lisp @code{define-module} makes this module available to Guile programs under the given @var{module-name}. @@ -541,9 +541,9 @@ duplication to the next handler in @var{list}. The default duplicate binding resolution policy is given by the @code{default-duplicate-binding-handler} procedure, and is -@smalllisp +@lisp (replace warn-override-core warn last) -@end smalllisp +@end lisp @item #:no-backtrace @cindex no backtrace @@ -1138,12 +1138,12 @@ gcc -shared -o libbessel.so -fPIC bessel.c Now fire up Guile: -@smalllisp +@lisp (define bessel-lib (dynamic-link "./libbessel.so")) (dynamic-call "init_math_bessel" bessel-lib) (j0 2) @result{} 0.223890779141236 -@end smalllisp +@end lisp The filename @file{./libbessel.so} should be pointing to the shared library produced with the @code{gcc} command above, of course. The diff --git a/doc/ref/api-options.texi b/doc/ref/api-options.texi index 20e32c51c..f7d0962df 100644 --- a/doc/ref/api-options.texi +++ b/doc/ref/api-options.texi @@ -82,10 +82,11 @@ general are stored. On Unix-like systems, this is usually @deffnx {C Function} scm_sys_library_dir () Return the name of the directory where the Guile Scheme files that belong to the core Guile installation (as opposed to files from a 3rd -party package) are installed. On Unix-like systems, this is usually +party package) are installed. On Unix-like systems this is usually @file{/usr/local/share/guile/<GUILE_EFFECTIVE_VERSION>} or -@file{/usr/share/guile/<GUILE_EFFECTIVE_VERSION>}, for example: -@file{/usr/local/share/guile/1.6}. +@file{/usr/share/guile/<GUILE_EFFECTIVE_VERSION>}; + +@noindent for example @file{/usr/local/share/guile/1.6}. @end deffn @deffn {Scheme Procedure} %site-dir @@ -503,9 +504,9 @@ Guile is case-sensitive by default. To make Guile case insensitive, you can type -@smalllisp +@lisp (read-enable 'case-insensitive) -@end smalllisp +@end lisp @node Printing options @subsubsection Printing options @@ -680,7 +681,8 @@ the maximum stack size, use @code{debug-set!}, for example: @lisp (debug-set! stack 200000) @result{} -(show-file-name #t stack 200000 debug backtrace depth 20 maxdepth 1000 frames 3 indent 10 width 79 procnames cheap) +(show-file-name #t stack 200000 debug backtrace depth 20 + maxdepth 1000 frames 3 indent 10 width 79 procnames cheap) (non-tail-recursive-factorial 500) @result{} @@ -717,7 +719,6 @@ backtrace. Need to give a better example, possibly putting debugging option examples in a separate session.] @end enumerate - @smalllisp guile> (define abc "hello") guile> abc diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi index 3b622868c..521369619 100644 --- a/doc/ref/api-scheduling.texi +++ b/doc/ref/api-scheduling.texi @@ -8,14 +8,9 @@ @node Scheduling @section Threads, Mutexes, Asyncs and Dynamic Roots -[FIXME: This is pasted in from Tom Lord's original guile.texi chapter -plus the Cygnus programmer's manual; it should be *very* carefully -reviewed and largely reorganized.] - @menu * Arbiters:: Synchronization primitives. * Asyncs:: Asynchronous procedure invocation. -* Continuation Barriers:: Protection from non-local control flow. * Threads:: Multiple threads of execution. * Mutexes and Condition Variables:: Synchronization primitives. * Blocking:: How to block properly in guile mode. @@ -47,7 +42,6 @@ process synchronization. @deffn {Scheme Procedure} try-arbiter arb @deffnx {C Function} scm_try_arbiter (arb) -@deffnx {C Function} scm_try_arbiter (arb) If @var{arb} is unlocked, then lock it and return @code{#t}. If @var{arb} is already locked, then do nothing and return @code{#f}. @@ -70,7 +64,7 @@ release it, but that's not required, any thread can release it. @cindex user asyncs @cindex system asyncs -Asyncs are a means of deferring the excution of Scheme code until it is +Asyncs are a means of deferring the execution of Scheme code until it is safe to do so. Guile provides two kinds of asyncs that share the basic concept but are @@ -132,43 +126,42 @@ This procedure is not safe to be called from signal handlers. Use signal handlers. @end deffn -@c FIXME: The use of @deffnx for scm_c_call_with_blocked_asyncs and -@c scm_c_call_with_unblocked_asyncs puts "void" into the function -@c index. Would prefer to use @deftypefnx if makeinfo allowed that, -@c or a @deftypefn with an empty return type argument if it didn't -@c introduce an extra space. - @deffn {Scheme Procedure} call-with-blocked-asyncs proc @deffnx {C Function} scm_call_with_blocked_asyncs (proc) -@deffnx {C Function} {void *} scm_c_call_with_blocked_asyncs (void * (*proc) (void *data), void *data) -@findex scm_c_call_with_blocked_asyncs Call @var{proc} and block the execution of system asyncs by one level for the current thread while it is running. Return the value returned by @var{proc}. For the first two variants, call @var{proc} with no arguments; for the third, call it with @var{data}. @end deffn +@deftypefn {C Function} {void *} scm_c_call_with_blocked_asyncs (void * (*proc) (void *data), void *data) +The same but with a C function @var{proc} instead of a Scheme thunk. +@end deftypefn + @deffn {Scheme Procedure} call-with-unblocked-asyncs proc @deffnx {C Function} scm_call_with_unblocked_asyncs (proc) -@deffnx {C Function} {void *} scm_c_call_with_unblocked_asyncs (void *(*p) (void *d), void *d) -@findex scm_c_call_with_unblocked_asyncs Call @var{proc} and unblock the execution of system asyncs by one level for the current thread while it is running. Return the value returned by @var{proc}. For the first two variants, call @var{proc} with no arguments; for the third, call it with @var{data}. @end deffn +@deftypefn {C Function} {void *} scm_c_call_with_unblocked_asyncs (void *(*proc) (void *data), void *data) +The same but with a C function @var{proc} instead of a Scheme thunk. +@end deftypefn + @deftypefn {C Function} void scm_dynwind_block_asyncs () -This function must be used inside a pair of calls to +During the current dynwind context, increase the blocking of asyncs by +one level. This function must be used inside a pair of calls to @code{scm_dynwind_begin} and @code{scm_dynwind_end} (@pxref{Dynamic -Wind}). During the dynwind context, asyncs are blocked by one level. +Wind}). @end deftypefn @deftypefn {C Function} void scm_dynwind_unblock_asyncs () -This function must be used inside a pair of calls to +During the current dynwind context, decrease the blocking of asyncs by +one level. This function must be used inside a pair of calls to @code{scm_dynwind_begin} and @code{scm_dynwind_end} (@pxref{Dynamic -Wind}). During the dynwind context, asyncs are unblocked by one -level. +Wind}). @end deftypefn @node User asyncs @@ -197,32 +190,6 @@ Mark the user async @var{a} for future execution. Execute all thunks from the marked asyncs of the list @var{list_of_a}. @end deffn -@node Continuation Barriers -@subsection Continuation Barriers - -The non-local flow of control caused by continuations might sometimes -not be wanted. You can use @code{with-continuation-barrier} etc to -errect fences that continuations can not pass. - -@deffn {Scheme Procedure} with-continuation-barrier proc -@deffnx {C Function} scm_with_continuation_barrier (proc) -Call @var{proc} and return its result. Do not allow the invocation of -continuations that would leave or enter the dynamic extent of the call -to @code{with-continuation-barrier}. Such an attempt causes an error -to be signaled. - -Throws (such as errors) that are not caught from within @var{proc} are -caught by @code{with-continuation-barrier}. In that case, a short -message is printed to the current error port and @code{#f} is returned. - -Thus, @code{with-continuation-barrier} returns exactly once. -@end deffn - -@deftypefn {C Function} {void *} scm_c_with_continuation_barrier (void *(*func) (void *), void *data) -Like @code{scm_with_continuation_barrier} but call @var{func} on -@var{data}. When an error is caught, @code{NULL} is returned. -@end deftypefn - @node Threads @subsection Threads @cindex threads diff --git a/doc/ref/autoconf.texi b/doc/ref/autoconf.texi index ba5800fc0..ae807c276 100644 --- a/doc/ref/autoconf.texi +++ b/doc/ref/autoconf.texi @@ -48,19 +48,18 @@ checks. @cindex pkg-config @cindex autoconf -GNU Guile provides a @dfn{pkg-config} description file, installed as -@file{@var{prefix}/lib/pkgconfig/guile-2.0.pc}, which contains all the -information necessary to compile and link C applications that use Guile. -The @code{pkg-config} program is able to read this file and provide this -information to application programmers; it can be obtained at -@url{http://pkg-config.freedesktop.org/}. +GNU Guile provides a @dfn{pkg-config} description file, which contains +all the information necessary to compile and link C applications that +use Guile. The @code{pkg-config} program is able to read this file +and provide this information to application programmers; it can be +obtained at @url{http://pkg-config.freedesktop.org/}. The following command lines give respectively the C compilation and link flags needed to build Guile-using programs: @example -pkg-config guile-2.0 --cflags -pkg-config guile-2.0 --libs +pkg-config guile-@value{EFFECTIVE-VERSION} --cflags +pkg-config guile-@value{EFFECTIVE-VERSION} --libs @end example To ease use of pkg-config with Autoconf, pkg-config comes with a @@ -71,7 +70,7 @@ accordingly, or prints an error and exits if Guile was not found: @findex PKG_CHECK_MODULES @example -PKG_CHECK_MODULES([GUILE], [guile-2.0]) +PKG_CHECK_MODULES([GUILE], [guile-@value{EFFECTIVE-VERSION}]) @end example Guile comes with additional Autoconf macros providing more information, diff --git a/doc/ref/compiler.texi b/doc/ref/compiler.texi index 0aea4e754..d749fc1f3 100644 --- a/doc/ref/compiler.texi +++ b/doc/ref/compiler.texi @@ -536,7 +536,8 @@ be wrapped in a thunk that declares the arity of the expression: @example scheme@@(guile-user)> ,language glil -Guile Lowlevel Intermediate Language (GLIL) interpreter 0.3 on Guile 1.9.0 +Guile Lowlevel Intermediate Language (GLIL) interpreter 0.3 on + Guile 1.9.0 Copyright (C) 2001-2008 Free Software Foundation, Inc. Enter `,help' for help. diff --git a/doc/ref/effective-version.texi.in b/doc/ref/effective-version.texi.in new file mode 100644 index 000000000..80b56b751 --- /dev/null +++ b/doc/ref/effective-version.texi.in @@ -0,0 +1 @@ +@set EFFECTIVE-VERSION @GUILE_EFFECTIVE_VERSION@ diff --git a/doc/ref/expect.texi b/doc/ref/expect.texi index 05c766999..71e9a385b 100644 --- a/doc/ref/expect.texi +++ b/doc/ref/expect.texi @@ -10,9 +10,9 @@ The macros in this section are made available with: -@smalllisp +@lisp (use-modules (ice-9 expect)) -@end smalllisp +@end lisp @code{expect} is a macro for selecting actions based on the output from a port. The name comes from a tool of similar functionality by Don Libes. @@ -30,14 +30,14 @@ which is matched against each of the patterns. When a pattern matches, the remaining expression(s) in the clause are evaluated and the value of the last is returned. For example: -@smalllisp +@lisp (with-input-from-file "/etc/passwd" (lambda () (expect-strings ("^nobody" (display "Got a nobody user.\n") (display "That's no problem.\n")) ("^daemon" (display "Got a daemon user.\n"))))) -@end smalllisp +@end lisp The regular expression is compiled with the @code{REG_NEWLINE} flag, so that the ^ and $ anchors will match at any newline, not just at the start @@ -54,13 +54,13 @@ The symbol @code{=>} can be used to indicate that the expression is a procedure which will accept the result of a successful regular expression match. E.g., -@smalllisp +@lisp ("^daemon" => write) ("^d(aemon)" => (lambda args (for-each write args))) ("^da(em)on" => (lambda (all sub) (write all) (newline) (write sub) (newline))) -@end smalllisp +@end lisp The order of the substrings corresponds to the order in which the opening brackets occur. @@ -135,12 +135,12 @@ expression. In the following example, a string will only be matched at the beginning of the file: -@smalllisp +@lisp (let ((expect-port (open-input-file "/etc/passwd"))) (expect ((lambda (s eof?) (string=? s "fnord!")) (display "Got a nobody user!\n")))) -@end smalllisp +@end lisp The control variables described for @code{expect-strings} also influence the behaviour of @code{expect}, with the exception of diff --git a/doc/goops/goops-tutorial.texi b/doc/ref/goops-tutorial.texi index 11155dfae..600be7730 100644 --- a/doc/goops/goops-tutorial.texi +++ b/doc/ref/goops-tutorial.texi @@ -1,3 +1,9 @@ +@c -*-texinfo-*- +@c This is part of the GNU Guile Reference Manual. +@c Copyright (C) 2008, 2009 +@c Free Software Foundation, Inc. +@c See the file guile.texi for copying conditions. + @c Original attribution: @c @@ -24,19 +30,33 @@ @c Guile @c @end macro -This is chapter was originally written by Erick Gallesio as an appendix -for the STk reference manual, and subsequently adapted to @goops{}. +This section introduces the @goops{} package in more detail. It was +originally written by Erick Gallesio as an appendix for the STk +reference manual, and subsequently adapted to @goops{}. + +The procedures and syntax described in this tutorial are provided by +Guile modules that may need to be imported before being available. +The main @goops{} module is imported by evaluating: + +@lisp +(use-modules (oop goops)) +@end lisp +@findex (oop goops) +@cindex main module +@cindex loading +@cindex preparing @menu * Copyright:: -* Intro:: -* Class definition and instantiation:: +* Class definition:: +* Instance creation and slot access:: +* Slot description:: * Inheritance:: * Generic functions:: @end menu -@node Copyright, Intro, Tutorial, Tutorial -@section Copyright +@node Copyright +@subsection Copyright Original attribution: @@ -52,52 +72,13 @@ required for any of the authorized uses. This software is provided ``AS IS'' without express or implied warranty. -Adapted for use in Guile with the authors permission - -@node Intro, Class definition and instantiation, Copyright, Tutorial -@section Introduction - -@goops{} is the object oriented extension to @guile{}. Its -implementation is derived from @w{STk-3.99.3} by Erick Gallesio and -version 1.3 of the Gregor Kiczales @cite{Tiny-Clos}. It is very close -to CLOS, the Common Lisp Object System (@cite{CLtL2}) but is adapted for -the Scheme language. - -Briefly stated, the @goops{} extension gives the user a full object -oriented system with multiple inheritance and generic functions with -multi-method dispatch. Furthermore, the implementation relies on a true -meta object protocol, in the spirit of the one defined for CLOS -(@cite{Gregor Kiczales: A Metaobject Protocol}). - -The purpose of this tutorial is to introduce briefly the @goops{} -package and in no case will it replace the @goops{} reference manual -(which needs to be urgently written now@ @dots{}). +Adapted for use in Guile with the author's permission -Note that the operations described in this tutorial resides in modules -that may need to be imported before being available. The main module is -imported by evaluating: - -@lisp -(use-modules (oop goops)) -@end lisp -@findex (oop goops) -@cindex main module -@cindex loading -@cindex preparing - -@node Class definition and instantiation, Inheritance, Intro, Tutorial -@section Class definition and instantiation - -@menu -* Class definition:: -@end menu - -@node Class definition, , Class definition and instantiation, Class definition and instantiation +@node Class definition @subsection Class definition -A new class is defined with the @code{define-class}@footnote{Don't -forget to import the @code{(oop goops)} module} macro. The syntax of -@code{define-class} is close to CLOS @code{defclass}: +A new class is defined with the @code{define-class} macro. The syntax +of @code{define-class} is close to CLOS @code{defclass}: @findex define-class @cindex class @@ -107,105 +88,36 @@ forget to import the @code{(oop goops)} module} macro. The syntax of @var{class-option} @dots{}) @end lisp -Class options will not be discussed in this tutorial. The list of -@var{superclass}es specifies which classes to inherit properties from -@var{class} (see @ref{Inheritance} for more details). A -@var{slot-description} gives the name of a slot and, eventually, some -``properties'' of this slot (such as its initial value, the function -which permit to access its value, @dots{}). Slot descriptions will be -discussed in @ref{Slot description}. +@var{class} is the class being defined. The list of +@var{superclass}es specifies which existing classes, if any, to +inherit slots and properties from. Each @var{slot-description} gives +the name of a slot and optionally some ``properties'' of this slot; +for example its initial value, the name of a function which will +access its value, and so on. Slot descriptions and inheritance are +discussed more below. For class options, see @ref{Class Options}. @cindex slot -As an example, let us define a type for representation of complex -numbers in terms of real numbers. This can be done with the following -class definition: +As an example, let us define a type for representing a complex number +in terms of two real numbers.@footnote{Of course Guile already +provides complex numbers, and @code{<complex>} is in fact a predefined +class in GOOPS; but the definition here is still useful as an +example.} This can be done with the following class definition: @lisp -(define-class <complex> (<number>) +(define-class <my-complex> (<number>) r i) @end lisp -This binds the variable @code{<complex>}@footnote{@code{<complex>} is in -fact a builtin class in GOOPS. Because of this, GOOPS will create a new -class. The old class will still serve as the type for Guile's native -complex numbers.} to a new class whose instances contain two -slots. These slots are called @code{r} an @code{i} and we suppose here -that they contain respectively the real part and the imaginary part of a -complex number. Note that this class inherits from @code{<number>} which -is a pre-defined class. (@code{<number>} is the direct super class of -the pre-defined class @code{<complex>} which, in turn, is the super -class of @code{<real>} which is the super of -@code{<integer>}.)@footnote{With the new definition of @code{<complex>}, -a @code{<real>} is not a @code{<complex>} since @code{<real>} inherits -from @code{ <number>} rather than @code{<complex>}. In practice, -inheritance could be modified @emph{a posteriori}, if needed. However, -this necessitates some knowledge of the meta object protocol and it will -not be shown in this document}. - -@node Inheritance, Generic functions, Class definition and instantiation, Tutorial -@section Inheritance -@c \label{inheritance} - -@menu -* Class hierarchy and inheritance of slots:: -* Instance creation and slot access:: -* Slot description:: -* Class precedence list:: -@end menu - -@node Class hierarchy and inheritance of slots, Instance creation and slot access, Inheritance, Inheritance -@subsection Class hierarchy and inheritance of slots -Inheritance is specified upon class definition. As said in the -introduction, @goops{} supports multiple inheritance. Here are some -class definitions: - -@lisp -(define-class A () a) -(define-class B () b) -(define-class C () c) -(define-class D (A B) d a) -(define-class E (A C) e c) -(define-class F (D E) f) -@end lisp - -@code{A}, @code{B}, @code{C} have a null list of super classes. In this -case, the system will replace it by the list which only contains -@code{<object>}, the root of all the classes defined by -@code{define-class}. @code{D}, @code{E}, @code{F} use multiple -inheritance: each class inherits from two previously defined classes. -Those class definitions define a hierarchy which is shown in Figure@ 1. -In this figure, the class @code{<top>} is also shown; this class is the -super class of all Scheme objects. In particular, @code{<top>} is the -super class of all standard Scheme types. - -@example -@group -@image{hierarchy} -@center @emph{Fig 1: A class hierarchy} -@iftex -@emph{(@code{<complex>} which is the direct subclass of @code{<number>} -and the direct superclass of @code{<real>} has been omitted in this -figure.)} -@end iftex -@end group -@end example - -The set of slots of a given class is calculated by taking the union of the -slots of all its super class. For instance, each instance of the class -D, defined before will have three slots (@code{a}, @code{b} and -@code{d}). The slots of a class can be obtained by the @code{class-slots} -primitive. For instance, - -@lisp -(class-slots A) @result{} ((a)) -(class-slots E) @result{} ((a) (e) (c)) -(class-slots F) @result{} ((e) (c) (b) (d) (a) (f)) -@c used to be ((d) (a) (b) (c) (f)) -@end lisp - -@emph{Note: } The order of slots is not significant. +This binds the variable @code{<my-complex>} to a new class whose +instances will contain two slots. These slots are called @code{r} and +@code{i} and will hold the real and imaginary parts of a complex +number. Note that this class inherits from @code{<number>}, which is a +predefined class.@footnote{@code{<number>} is the direct superclass of +the predefined class @code{<complex>}; @code{<complex>} is the +superclass of @code{<real>}, and @code{<real>} is the superclass of +@code{<integer>}.} -@node Instance creation and slot access, Slot description, Class hierarchy and inheritance of slots, Inheritance +@node Instance creation and slot access @subsection Instance creation and slot access Creation of an instance of a previously defined @@ -218,16 +130,16 @@ slots of the newly created instance. For instance, the following form @findex make @cindex instance @lisp -(define c (make <complex>)) +(define c (make <my-complex>)) @end lisp -will create a new @code{<complex>} object and will bind it to the @code{c} +@noindent +will create a new @code{<my-complex>} object and will bind it to the @code{c} Scheme variable. Accessing the slots of the new complex number can be done with the -@code{slot-ref} and the @code{slot-set!} primitives. @code{Slot-set!} -primitive permits to set the value of an object slot and @code{slot-ref} -permits to get its value. +@code{slot-ref} and the @code{slot-set!} primitives. @code{slot-set!} +sets the value of an object slot and @code{slot-ref} retrieves it. @findex slot-set! @findex slot-ref @@ -250,52 +162,60 @@ First load the module @code{(oop goops describe)}: @code{(use-modules (oop goops describe))} @end example -The expression +@noindent +Then the expression -@smalllisp +@lisp (describe c) -@end smalllisp +@end lisp -will now print the following information on the standard output: +@noindent +will print the following information on the standard output: -@lisp -#<<complex> 401d8638> is an instance of class <complex> +@smalllisp +#<<my-complex> 401d8638> is an instance of class <my-complex> Slots are: r = 10 i = 3 -@end lisp +@end smalllisp -@node Slot description, Class precedence list, Instance creation and slot access, Inheritance +@node Slot description @subsection Slot description @c \label{slot-description} -When specifying a slot, a set of options can be given to the -system. Each option is specified with a keyword. The list of authorized -keywords is given below: +When specifying a slot (in a @code{(define-class @dots{})} form), +various options can be specified in addition to the slot's name. Each +option is specified by a keyword. The list of authorized keywords is +given below: @cindex keyword @itemize @bullet @item -@code{#:init-value} permits to supply a default value for the slot. This -default value is obtained by evaluating the form given after the -@code{#:init-form} in the global environment, at class definition time. +@code{#:init-value} permits to supply a constant default value for the +slot. The value is obtained by evaluating the form given after the +@code{#:init-value} at class definition time. @cindex default slot value @findex #:init-value -@cindex top level environment + +@item +@code{#:init-form} specifies a form that, when evaluated, will return +an initial value for the slot. The form is evaluated each time that +an instance of the class is created, in the lexical environment of the +containing @code{define-class} expression. +@cindex default slot value +@findex #:init-form @item @code{#:init-thunk} permits to supply a thunk that will provide a -default value for the slot. The value is obtained by evaluating the -thunk a instance creation time. -@c CHECKME: in the global environment? +default value for the slot. The value is obtained by invoking the +thunk at instance creation time. @findex default slot value @findex #:init-thunk -@cindex top level environment @item -@code{#:init-keyword} permits to specify the keyword for initializing a -slot. The init-keyword may be provided during instance creation (i.e. in -the @code{make} optional parameter list). Specifying such a keyword +@code{#:init-keyword} permits to specify a keyword for initializing the +slot. The init-keyword may be provided during instance creation (i.e. in +the @code{make} optional parameter list). Specifying such a keyword during instance initialization will supersede the default slot initialization possibly given with @code{#:init-form}. @findex #:init-keyword @@ -361,11 +281,11 @@ and @code{#:slot-set!} options. See the example below. @end itemize @end itemize -To illustrate slot description, we shall redefine the @code{<complex>} class +To illustrate slot description, we shall redefine the @code{<my-complex>} class seen before. A definition could be: @lisp -(define-class <complex> (<number>) +(define-class <my-complex> (<number>) (r #:init-value 0 #:getter get-r #:setter set-r! #:init-keyword #:r) (i #:init-value 0 #:getter get-i #:setter set-i! #:init-keyword #:i)) @end lisp @@ -378,11 +298,11 @@ functions @code{get-r} and @code{set-r!} (resp. @code{get-i} and the @code{r} (resp. @code{i}) slot. @lisp -(define c1 (make <complex> #:r 1 #:i 2)) +(define c1 (make <my-complex> #:r 1 #:i 2)) (get-r c1) @result{} 1 (set-r! c1 12) (get-r c1) @result{} 12 -(define c2 (make <complex> #:r 2)) +(define c2 (make <my-complex> #:r 2)) (get-r c2) @result{} 2 (get-i c2) @result{} 0 @end lisp @@ -390,12 +310,12 @@ the @code{r} (resp. @code{i}) slot. Accessors provide an uniform access for reading and writing an object slot. Writing a slot is done with an extended form of @code{set!} which is close to the Common Lisp @code{setf} macro. So, another -definition of the previous @code{<complex>} class, using the +definition of the previous @code{<my-complex>} class, using the @code{#:accessor} option, could be: @findex set! @lisp -(define-class <complex> (<number>) +(define-class <my-complex> (<number>) (r #:init-value 0 #:accessor real-part #:init-keyword #:r) (i #:init-value 0 #:accessor imag-part #:init-keyword #:i)) @end lisp @@ -416,13 +336,13 @@ coordinates as well as with polar coordinates. One solution could be to have a definition of complex numbers which uses one particular representation and some conversion functions to pass from one representation to the other. A better solution uses virtual slots. A -complete definition of the @code{<complex>} class using virtual slots is +complete definition of the @code{<my-complex>} class using virtual slots is given in Figure@ 2. @example @group @lisp -(define-class <complex> (<number>) +(define-class <my-complex> (<number>) ;; True slots use rectangular coordinates (r #:init-value 0 #:accessor real-part #:init-keyword #:r) (i #:init-value 0 #:accessor imag-part #:init-keyword #:i) @@ -446,7 +366,7 @@ given in Figure@ 2. (slot-set! o 'i (* m (sin a))))))) @end lisp -@center @emph{Fig 2: A @code{<complex>} number class definition using virtual slots} +@center @emph{Fig 2: A @code{<my-complex>} number class definition using virtual slots} @end group @end example @@ -480,20 +400,21 @@ A more complete example is given below: @example @group -@lisp -(define c (make <complex> #:r 12 #:i 20)) +@smalllisp +(define c (make <my-complex> #:r 12 #:i 20)) (real-part c) @result{} 12 (angle c) @result{} 1.03037682652431 (slot-set! c 'i 10) (set! (real-part c) 1) -(describe c) @result{} - #<<complex> 401e9b58> is an instance of class <complex> - Slots are: - r = 1 - i = 10 - m = 10.0498756211209 - a = 1.47112767430373 -@end lisp +(describe c) +@print{} +#<<my-complex> 401e9b58> is an instance of class <my-complex> +Slots are: + r = 1 + i = 10 + m = 10.0498756211209 + a = 1.47112767430373 +@end smalllisp @end group @end example @@ -503,14 +424,75 @@ Scheme primitives. @lisp (define make-rectangular - (lambda (x y) (make <complex> #:r x #:i y))) + (lambda (x y) (make <my-complex> #:r x #:i y))) (define make-polar - (lambda (x y) (make <complex> #:magn x #:angle y))) + (lambda (x y) (make <my-complex> #:magn x #:angle y))) +@end lisp + +@node Inheritance +@subsection Inheritance +@c \label{inheritance} + +@menu +* Class hierarchy and inheritance of slots:: +* Class precedence list:: +@end menu + +@node Class hierarchy and inheritance of slots +@subsubsection Class hierarchy and inheritance of slots +Inheritance is specified upon class definition. As said in the +introduction, @goops{} supports multiple inheritance. Here are some +class definitions: + +@lisp +(define-class A () a) +(define-class B () b) +(define-class C () c) +(define-class D (A B) d a) +(define-class E (A C) e c) +(define-class F (D E) f) @end lisp -@node Class precedence list, , Slot description, Inheritance -@subsection Class precedence list +@code{A}, @code{B}, @code{C} have a null list of super classes. In this +case, the system will replace it by the list which only contains +@code{<object>}, the root of all the classes defined by +@code{define-class}. @code{D}, @code{E}, @code{F} use multiple +inheritance: each class inherits from two previously defined classes. +Those class definitions define a hierarchy which is shown in Figure@ 1. +In this figure, the class @code{<top>} is also shown; this class is the +super class of all Scheme objects. In particular, @code{<top>} is the +super class of all standard Scheme types. + +@example +@group +@image{hierarchy} +@center @emph{Fig 1: A class hierarchy} +@iftex +@emph{(@code{<complex>} which is the direct subclass of @code{<number>} +and the direct superclass of @code{<real>} has been omitted in this +figure.)} +@end iftex +@end group +@end example + +The set of slots of a given class is calculated by taking the union of the +slots of all its super class. For instance, each instance of the class +D, defined before will have three slots (@code{a}, @code{b} and +@code{d}). The slots of a class can be obtained by the @code{class-slots} +primitive. For instance, + +@lisp +(class-slots A) @result{} ((a)) +(class-slots E) @result{} ((a) (e) (c)) +(class-slots F) @result{} ((e) (c) (b) (d) (a) (f)) +@c used to be ((d) (a) (b) (c) (f)) +@end lisp + +@emph{Note: } The order of slots is not significant. + +@node Class precedence list +@subsubsection Class precedence list A class may have more than one superclass. @footnote{This section is an adaptation of Jeff Dalton's (J.Dalton@@ed.ac.uk) @cite{Brief @@ -587,8 +569,8 @@ However, this result is not too much readable; using the function (map class-name (class-precedence-list B)) @result{} (B <object> <top>) @end lisp -@node Generic functions, , Inheritance, Tutorial -@section Generic functions +@node Generic functions +@subsection Generic functions @menu * Generic functions and methods:: @@ -596,8 +578,8 @@ However, this result is not too much readable; using the function * Example:: @end menu -@node Generic functions and methods, Next-method, Generic functions, Generic functions -@subsection Generic functions and methods +@node Generic functions and methods +@subsubsection Generic functions and methods @c \label{gf-n-methods} Neither @goops{} nor CLOS use the message mechanism for methods as most @@ -687,8 +669,8 @@ In this case, (G 'a 1) @result{} top-number @end lisp -@node Next-method, Example, Generic functions and methods, Generic functions -@subsection Next-method +@node Next-method +@subsubsection Next-method When you call a generic function, with a particular set of arguments, GOOPS builds a list of all the methods that are applicable to those @@ -737,16 +719,16 @@ Number is in range lead to an infinite recursion, but this consideration is just the same as in Scheme code in general.) -@node Example, , Next-method, Generic functions -@subsection Example +@node Example +@subsubsection Example -In this section we shall continue to define operations on the @code{<complex>} +In this section we shall continue to define operations on the @code{<my-complex>} class defined in Figure@ 2. Suppose that we want to use it to implement complex numbers completely. For instance a definition for the addition of two complexes could be @lisp -(define-method (new-+ (a <complex>) (b <complex>)) +(define-method (new-+ (a <my-complex>) (b <my-complex>)) (make-rectangular (+ (real-part a) (real-part b)) (+ (imag-part a) (imag-part b)))) @end lisp @@ -758,7 +740,7 @@ addition we can do: (define-generic new-+) (let ((+ +)) - (define-method (new-+ (a <complex>) (b <complex>)) + (define-method (new-+ (a <my-complex>) (b <my-complex>)) (make-rectangular (+ (real-part a) (real-part b)) (+ (imag-part a) (imag-part b))))) @end lisp @@ -778,13 +760,13 @@ Figure@ 3. (define-method (new-+ (a <real>) (b <real>)) (+ a b)) - (define-method (new-+ (a <real>) (b <complex>)) + (define-method (new-+ (a <real>) (b <my-complex>)) (make-rectangular (+ a (real-part b)) (imag-part b))) - (define-method (new-+ (a <complex>) (b <real>)) + (define-method (new-+ (a <my-complex>) (b <real>)) (make-rectangular (+ (real-part a) b) (imag-part a))) - (define-method (new-+ (a <complex>) (b <complex>)) + (define-method (new-+ (a <my-complex>) (b <my-complex>)) (make-rectangular (+ (real-part a) (real-part b)) (+ (imag-part a) (imag-part b)))) @@ -823,7 +805,7 @@ To terminate our implementation (integration?) of complex numbers, we can redefine standard Scheme predicates in the following manner: @lisp -(define-method (complex? c <complex>) #t) +(define-method (complex? c <my-complex>) #t) (define-method (complex? c) #f) (define-method (number? n <number>) #t) diff --git a/doc/goops/goops.texi b/doc/ref/goops.texi index d6d8e595d..c0a828f71 100644 --- a/doc/goops/goops.texi +++ b/doc/ref/goops.texi @@ -1,19 +1,8 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename goops.info -@settitle Goops Manual -@set goops -@setchapternewpage odd -@paragraphindent 0 -@c %**end of header - -@set VERSION 0.3 - -@dircategory The Algorithmic Language Scheme -@direntry -* GOOPS: (goops). The GOOPS reference manual. -@end direntry +@c This is part of the GNU Guile Reference Manual. +@c Copyright (C) 2008, 2009 +@c Free Software Foundation, Inc. +@c See the file guile.texi for copying conditions. @macro goops GOOPS @@ -23,77 +12,8 @@ GOOPS Guile @end macro -@ifinfo -This file documents GOOPS, an object oriented extension for Guile. - -Copyright (C) 1999, 2000, 2001, 2003, 2006 Free Software Foundation - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@end ifinfo - -@c This title page illustrates only one of the -@c two methods of forming a title page. - -@titlepage -@title Goops Manual -@subtitle For use with GOOPS @value{VERSION} - -@c AUTHORS - -@c The GOOPS tutorial was written by Christian Lynbech and Mikael -@c Djurfeldt, who also wrote GOOPS itself. The GOOPS reference manual -@c and MOP documentation were written by Neil Jerram and reviewed by -@c Mikael Djurfeldt. - -@author Christian Lynbech -@author @email{chl@@tbit.dk} -@author -@author Mikael Djurfeldt -@author @email{djurfeldt@@nada.kth.se} -@author -@author Neil Jerram -@author @email{neil@@ossau.uklinux.net} - -@c The following two commands -@c start the copyright page. -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1999, 2006 Free Software Foundation - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@end titlepage - -@node Top, Introduction, (dir), (dir) - -@menu -* Introduction:: -* Getting Started:: -* Reference Manual:: -* MOP Specification:: - -* Tutorial:: - -* Concept Index:: -* Function and Variable Index:: -@end menu - -@iftex -@chapter Preliminaries -@end iftex - -@node Introduction, Getting Started, Top, Top -@iftex -@section Introduction -@end iftex -@ifnottex -@chapter Introduction -@end ifnottex +@node GOOPS +@chapter GOOPS @goops{} is the object oriented extension to @guile{}. Its implementation is derived from @w{STk-3.99.3} by Erick Gallesio and @@ -109,71 +29,58 @@ multi-method dispatch. Furthermore, the implementation relies on a true meta object protocol, in the spirit of the one defined for CLOS (@cite{Gregor Kiczales: A Metaobject Protocol}). -@node Getting Started, Reference Manual, Introduction, Top -@iftex -@section Getting Started -@end iftex -@ifnottex -@chapter Getting Started -@end ifnottex - @menu -* Running GOOPS:: - -Examples of some basic GOOPS functionality. - -* Methods:: -* User-defined types:: -* Asking for the type of an object:: - -See further in the GOOPS tutorial available in this distribution in -info (goops.info) and texinfo format. +* Quick Start:: +* Tutorial:: +* Reference Manual:: +* MOP Specification:: @end menu -@node Running GOOPS, Methods, Getting Started, Getting Started -@subsection Running GOOPS - -@enumerate -@item -Type - -@smalllisp -guile-oops -@end smalllisp +@node Quick Start +@section Quick Start -You should now be at the Guile prompt ("guile> "). +To give an immediate flavour of what GOOPS can do, here is a very +brief introduction to its main operations. -@item -Type +To start using GOOPS, load the @code{(oop goops)} module: -@smalllisp +@lisp (use-modules (oop goops)) -@end smalllisp - -to load GOOPS. (If your system supports dynamic loading, you -should be able to do this not only from `guile-oops' but from an -arbitrary Guile interpreter.) -@end enumerate +@end lisp We're now ready to try some basic GOOPS functionality. -@node Methods, User-defined types, Running GOOPS, Getting Started +@menu +* Methods:: +* User-defined types:: +* Asking for the type of an object:: +@end menu + +@node Methods @subsection Methods -@smalllisp -@group +A GOOPS method is like a Scheme procedure except that it is +specialized for a particular set of argument types. + +@lisp (define-method (+ (x <string>) (y <string>)) (string-append x y)) -(+ 1 2) --> 3 -(+ "abc" "de") --> "abcde" -@end group -@end smalllisp +(+ "abc" "de") @result{} "abcde" +@end lisp -@node User-defined types, Asking for the type of an object, Methods, Getting Started +If @code{+} is used with arguments that do not match the method's +types, Guile falls back to using the normal Scheme @code{+} procedure. + +@lisp +(+ 1 2) @result{} 3 +@end lisp + + +@node User-defined types @subsection User-defined types -@smalllisp +@lisp (define-class <2D-vector> () (x #:init-value 0 #:accessor x-component #:init-keyword #:x) (y #:init-value 0 #:accessor y-component #:init-keyword #:y)) @@ -182,12 +89,11 @@ We're now ready to try some basic GOOPS functionality. (use-modules (ice-9 format)) (define-method (write (obj <2D-vector>) port) - (display (format #f "<~S, ~S>" (x-component obj) (y-component obj)) - port)) + (format port "<~S, ~S>" (x-component obj) (y-component obj))) (define v (make <2D-vector> #:x 3 #:y 4)) -v --> <3, 4> +v @result{} <3, 4> @end group @group @@ -196,24 +102,28 @@ v --> <3, 4> #:x (+ (x-component x) (x-component y)) #:y (+ (y-component x) (y-component y)))) -(+ v v) --> <6, 8> +(+ v v) @result{} <6, 8> @end group -@end smalllisp +@end lisp -@node Asking for the type of an object, , User-defined types, Getting Started +@node Asking for the type of an object @subsection Types @example -(class-of v) --> #<<class> <2D-vector> 40241ac0> -<2D-vector> --> #<<class> <2D-vector> 40241ac0> -(class-of 1) --> #<<class> <integer> 401b2a98> -<integer> --> #<<class> <integer> 401b2a98> +(class-of v) @result{} #<<class> <2D-vector> 40241ac0> +<2D-vector> @result{} #<<class> <2D-vector> 40241ac0> +(class-of 1) @result{} #<<class> <integer> 401b2a98> +<integer> @result{} #<<class> <integer> 401b2a98> -(is-a? v <2D-vector>) --> #t +(is-a? v <2D-vector>) @result{} #t @end example -@node Reference Manual, MOP Specification, Getting Started, Top -@chapter Reference Manual +@node Tutorial +@section Tutorial +@include goops-tutorial.texi + +@node Reference Manual +@section Reference Manual This chapter is the GOOPS reference manual. It aims to describe all the syntax, procedures, options and associated concepts that a typical @@ -241,7 +151,7 @@ For a detailed specification of the GOOPS metaobject protocol, see @end menu @node Introductory Remarks -@section Introductory Remarks +@subsection Introductory Remarks GOOPS is an object-oriented programming system based on a ``metaobject protocol'' derived from the ones used in CLOS (the Common Lisp Object @@ -261,19 +171,19 @@ GOOPS' power, by customizing the behaviour of GOOPS itself. Each of the following sections of the reference manual is arranged such that the most basic usage is introduced first, and then subsequent -subsections discuss the related internal functions and metaobject +subsubsections discuss the related internal functions and metaobject protocols, finishing with a description of how to customize that area of functionality. These introductory remarks continue with a few words about metaobjects and the MOP. Readers who do not want to be bothered yet with the MOP -and customization could safely skip this subsection on a first reading, -and should correspondingly skip subsequent subsections that are +and customization could safely skip this subsubsection on a first reading, +and should correspondingly skip subsequent subsubsections that are concerned with internals and customization. In general, this reference manual assumes familiarity with standard object oriented concepts and terminology. However, some of the terms -used in GOOPS are less well known, so the Terminology subsection +used in GOOPS are less well known, so the Terminology subsubsection provides definitions for these terms. @menu @@ -282,7 +192,7 @@ provides definitions for these terms. @end menu @node Metaobjects and the Metaobject Protocol -@subsection Metaobjects and the Metaobject Protocol +@subsubsection Metaobjects and the Metaobject Protocol The conceptual building blocks of GOOPS are classes, slot definitions, instances, generic functions and methods. A class is a grouping of @@ -377,7 +287,7 @@ Each subsequent section of the reference manual covers a particular area of GOOPS functionality, and describes the generic functions that are relevant for customization of that area. -We conclude this subsection by emphasizing a point that may seem +We conclude this subsubsection by emphasizing a point that may seem obvious, but contrasts with the corresponding situation in some other MOP implementations, such as CLOS. The point is simply that an identifier which represents a GOOPS class or generic function is a @@ -392,7 +302,7 @@ class names), but it is worth noting that GOOPS conforms fully to this Schemely principle. @node Terminology -@subsection Terminology +@subsubsection Terminology It is assumed that the reader is already familiar with standard object orientation concepts such as classes, objects/instances, @@ -403,14 +313,7 @@ This section explains some of the less well known concepts and terminology that GOOPS uses, which are assumed by the following sections of the reference manual. -@menu -* Metaclass:: -* Class Precedence List:: -* Accessor:: -@end menu - -@node Metaclass -@subsubsection Metaclass +@subsubheading Metaclass A @dfn{metaclass} is the class of an object which represents a GOOPS class. Put more succinctly, a metaclass is a class's class. @@ -517,8 +420,7 @@ The metaclass of @code{<my-metaclass>} is @code{<class>}. @code{<class>}. @end itemize -@node Class Precedence List -@subsubsection Class Precedence List +@subsubheading Class Precedence List The @dfn{class precedence list} of a class is the list of all direct and indirect superclasses of that class, including the class itself. @@ -548,8 +450,7 @@ precedence list}. ``Class precedence list'' is often abbreviated, in documentation and Scheme variable names, to @dfn{cpl}. -@node Accessor -@subsubsection Accessor +@subsubheading Accessor An @dfn{accessor} is a generic function with both reference and setter methods. @@ -583,7 +484,7 @@ be invoked using the generalized @code{set!} syntax, as in: @end example @node Defining New Classes -@section Defining New Classes +@subsection Defining New Classes [ *fixme* Somewhere in this manual there needs to be an introductory discussion about GOOPS classes, generic functions and methods, covering @@ -622,7 +523,7 @@ the discussion there. ] @end menu @node Basic Class Definition -@subsection Basic Class Definition +@subsubsection Basic Class Definition New classes are defined using the @code{define-class} syntax, with arguments that specify the classes that the new class should inherit @@ -651,7 +552,7 @@ keywords and corresponding values. @end deffn The standard GOOPS class and slot options are described in the following -subsections: see @ref{Class Options} and @ref{Slot Options}. +subsubsections: see @ref{Class Options} and @ref{Slot Options}. Example 1. Define a class that combines two pre-existing classes by inheritance but adds no new slots. @@ -681,13 +582,13 @@ customized via an application-defined metaclass. @end example @node Class Options -@subsection Class Options +@subsubsection Class Options @deffn {class option} #:metaclass metaclass The @code{#:metaclass} class option specifies the metaclass of the class being defined. @var{metaclass} must be a class that inherits from @code{<class>}. For an introduction to the use of metaclasses, see -@ref{Metaobjects and the Metaobject Protocol} and @ref{Metaclass}. +@ref{Metaobjects and the Metaobject Protocol} and @ref{Terminology}. If the @code{#:metaclass} option is absent, GOOPS reuses or constructs a metaclass for the new class by calling @code{ensure-metaclass} @@ -714,7 +615,7 @@ environment defaults to the top-level environment in which the @end deffn @node Slot Options -@subsection Slot Options +@subsubsection Slot Options @deffn {slot option} #:allocation allocation The @code{#:allocation} option tells GOOPS how to allocate storage for @@ -917,7 +818,7 @@ classes. @end deffn @node Class Definition Internals -@subsection Class Definition Internals +@subsubsection Class Definition Internals Implementation notes: @code{define-class} expands to an expression which @@ -1030,7 +931,7 @@ class object, are described in @ref{Customizing Instance Creation}, which covers the creation and initialization of instances in general. @node Customizing Class Definition -@subsection Customizing Class Definition +@subsubsection Customizing Class Definition During the initialization of a new class, GOOPS calls a number of generic functions with the newly allocated class instance as the first @@ -1124,7 +1025,8 @@ allocation to do this. (let ((batch-allocation-count 0) (batch-get-n-set #f)) - (define-method (compute-get-n-set (class <batched-allocation-metaclass>) s) + (define-method (compute-get-n-set + (class <batched-allocation-metaclass>) s) (case (slot-definition-allocation s) ((#:batched) ;; If we've already used the same slot storage for 10 instances, @@ -1165,7 +1067,7 @@ typically it would perform additional class initialization steps before and/or after calling @code{(next-method)} for the standard behaviour. @node STKlos Compatibility -@subsection STKlos Compatibility +@subsubsection STKlos Compatibility If the STKlos compatibility module is loaded, @code{define-class} is overwritten by a STKlos-specific definition; the standard GOOPS @@ -1178,7 +1080,7 @@ definition of @code{define-class} remains available in @end deffn @node Creating Instances -@section Creating Instances +@subsection Creating Instances @menu * Basic Instance Creation:: @@ -1186,7 +1088,7 @@ definition of @code{define-class} remains available in @end menu @node Basic Instance Creation -@subsection Basic Instance Creation +@subsubsection Basic Instance Creation To create a new instance of any GOOPS class, use the generic function @code{make} or @code{make-instance}, passing the required class and any @@ -1223,7 +1125,7 @@ instance's class. Any unprocessed keyword value pairs are ignored. @end deffn @node Customizing Instance Creation -@subsection Customizing Instance Creation +@subsubsection Customizing Instance Creation @code{make} itself is a generic function. Hence the @code{make} invocation itself can be customized in the case where the new instance's @@ -1290,7 +1192,7 @@ and closures in the slot definitions, it is neater to write an and initializes all the dependent slot values according to the results. @node Accessing Slots -@section Accessing Slots +@subsection Accessing Slots The definition of a slot contains at the very least a slot name, and may also contain various slot options, including getter, setter and/or @@ -1298,7 +1200,7 @@ accessor functions for the slot. It is always possible to access slots by name, using the various ``slot-ref'' and ``slot-set!'' procedures described in the following -subsections. For example, +subsubsections. For example, @example (define-class <my-class> () ;; Define a class with slots @@ -1354,7 +1256,7 @@ closures, see @ref{Customizing Class Definition,, compute-get-n-set}.) @end menu @node Instance Slots -@subsection Instance Slots +@subsubsection Instance Slots Any slot, regardless of its allocation, can be queried, referenced and set using the following four primitive procedures. @@ -1451,7 +1353,7 @@ slot-missing}). @end deffn @node Class Slots -@subsection Class Slots +@subsubsection Class Slots Slots whose allocation is per-class rather than per-instance can be referenced and set without needing to specify any particular instance. @@ -1479,7 +1381,7 @@ function with arguments @var{class} and @var{slot-name}. @end deffn @node Handling Slot Access Errors -@subsection Handling Slot Access Errors +@subsubsection Handling Slot Access Errors GOOPS calls one of the following generic functions when a ``slot-ref'' or ``slot-set!'' call specifies a non-existent slot name, or tries to @@ -1510,7 +1412,7 @@ message. @end deffn @node Creating Generic Functions -@section Creating Generic Functions +@subsection Creating Generic Functions A generic function is a collection of methods, with rules for determining which of the methods should be applied for any given @@ -1526,7 +1428,7 @@ GOOPS represents generic functions as metaobjects of the class @end menu @node Basic Generic Function Creation -@subsection Basic Generic Function Creation +@subsubsection Basic Generic Function Creation The following forms may be used to bind a variable to a generic function. Depending on that variable's pre-existing value, the generic @@ -1586,20 +1488,20 @@ This can be resolved automagically with the duplicates handler @code{merge-generics} which gives the module system license to merge all generic functions sharing a common name: -@smalllisp +@lisp (define-module (math 2D-vectors) - :use-module (oop goops) - :export (x y ...)) + #:use-module (oop goops) + #:export (x y ...)) (define-module (math 3D-vectors) - :use-module (oop goops) - :export (x y z ...)) + #:use-module (oop goops) + #:export (x y z ...)) (define-module (my-module) - :use-module (math 2D-vectors) - :use-module (math 3D-vectors) - :duplicates merge-generics) -@end smalllisp + #:use-module (math 2D-vectors) + #:use-module (math 3D-vectors) + #:duplicates merge-generics) +@end lisp The generic function @code{x} in @code{(my-module)} will now share methods with @code{x} in both imported modules. @@ -1629,14 +1531,14 @@ Sharing is dynamic, so that adding new methods to a descendant implies adding it to the ancestor. If duplicates checking is desired in the above example, the following -form of the @code{:duplicates} option can be used instead: +form of the @code{#:duplicates} option can be used instead: -@smalllisp - :duplicates (merge-generics check) -@end smalllisp +@lisp + #:duplicates (merge-generics check) +@end lisp @node Generic Function Internals -@subsection Generic Function Internals +@subsubsection Generic Function Internals @code{define-generic} calls @code{ensure-generic} to upgrade a pre-existing procedure value, or @code{make} with metaclass @@ -1705,7 +1607,7 @@ accessor, passing the setter generic function as the value of the @code{#:setter} keyword. @node Extending Guiles Primitives -@subsection Extending Guile's Primitives +@subsubsection Extending Guile's Primitives When GOOPS is loaded, many of Guile's primitive procedures can be extended by giving them a generic function definition that operates @@ -1752,7 +1654,7 @@ integrated into the core of Guile. Consequently, the procedures described in this section may disappear as well. @node Adding Methods to Generic Functions -@section Adding Methods to Generic Functions +@subsection Adding Methods to Generic Functions @menu * Basic Method Definition:: @@ -1760,7 +1662,7 @@ procedures described in this section may disappear as well. @end menu @node Basic Method Definition -@subsection Basic Method Definition +@subsubsection Basic Method Definition To add a method to a generic function, use the @code{define-method} form. @@ -1819,7 +1721,7 @@ invocation error handling, and generic function invocation in general, see @ref{Invoking Generic Functions}. @node Method Definition Internals -@subsection Method Definition Internals +@subsubsection Method Definition Internals @code{define-method} @@ -1906,7 +1808,7 @@ function. @end deffn @node Invoking Generic Functions -@section Invoking Generic Functions +@subsection Invoking Generic Functions When a variable with a generic function definition appears as the first element of a list that is being evaluated, the Guile evaluator tries @@ -1928,7 +1830,7 @@ may be applied subsequently if a method that is being applied calls @end menu @node Determining Which Methods to Apply -@subsection Determining Which Methods to Apply +@subsubsection Determining Which Methods to Apply [ *fixme* Sorry - this is the area of GOOPS that I understand least of all, so I'm afraid I have to pass on this section. Would some other @@ -1959,7 +1861,7 @@ kind person consider filling it in? ] @end deffn @node Handling Invocation Errors -@subsection Handling Invocation Errors +@subsubsection Handling Invocation Errors @deffn generic no-method @deffnx method no-method (gf <generic>) args @@ -1987,7 +1889,7 @@ default method calls @code{goops-error} with an appropriate message. @end deffn @node Redefining a Class -@section Redefining a Class +@subsection Redefining a Class Suppose that a class @code{<my-class>} is defined using @code{define-class} (@pxref{Basic Class Definition,, define-class}), with slots that have @@ -2002,7 +1904,7 @@ make}). What then happens if @code{<my-class>} is redefined by calling @end menu @node Default Class Redefinition Behaviour -@subsection Default Class Redefinition Behaviour +@subsubsection Default Class Redefinition Behaviour GOOPS' default answer to this question is as follows. @@ -2055,7 +1957,7 @@ Also bear in mind that, like most of GOOPS' default behaviour, it can be customized@dots{} @node Customizing Class Redefinition -@subsection Customizing Class Redefinition +@subsubsection Customizing Class Redefinition When @code{define-class} notices that a class is being redefined, it constructs the new class metaobject as usual, and then invokes the @@ -2092,7 +1994,8 @@ is specialized for this metaclass: @example (define-class <can-be-nameless> (<class>)) -(define-method (class-redefinition (old <can-be-nameless>) (new <class>)) +(define-method (class-redefinition (old <can-be-nameless>) + (new <class>)) new) @end example @@ -2119,7 +2022,7 @@ generic functions, and so on@dots{} The detailed protocol for all of these is described in @ref{MOP Specification}. @node Changing the Class of an Instance -@section Changing the Class of an Instance +@subsection Changing the Class of an Instance You can change the class of an existing instance by invoking the generic function @code{change-class} with two arguments: the instance @@ -2158,7 +2061,7 @@ invokes the @code{change-class} generic function for each existing instance of the redefined class. @node Introspection -@section Introspection +@subsection Introspection @dfn{Introspection}, also known as @dfn{reflection}, is the name given to the ability to obtain information dynamically about GOOPS metaobjects. @@ -2197,7 +2100,7 @@ GOOPS equivalents --- to be obtained dynamically, at run time. @end menu @node Classes -@subsection Classes +@subsubsection Classes @deffn {primitive procedure} class-name class Return the name of class @var{class}. @@ -2257,7 +2160,7 @@ Return a list of all methods that use @var{class} or a subclass of @end deffn @node Slots -@subsection Slots +@subsubsection Slots @deffn procedure class-slot-definition class slot-name Return the slot definition for the slot named @var{slot-name} in class @@ -2338,7 +2241,7 @@ see @ref{Slot Options,, init-value}. @end deffn @node Instances -@subsection Instances +@subsubsection Instances @deffn {primitive procedure} class-of value Return the GOOPS class of any Scheme @var{value}. @@ -2359,7 +2262,7 @@ Implementation notes: @code{is-a?} uses @code{class-of} and @var{object}. @node Generic Functions -@subsection Generic Functions +@subsubsection Generic Functions @deffn {primitive procedure} generic-function-name gf Return the name of generic function @var{gf}. @@ -2371,7 +2274,7 @@ This is the value of the @var{gf} metaobject's @code{methods} slot. @end deffn @node Generic Function Methods -@subsection Generic Function Methods +@subsubsection Generic Function Methods @deffn {primitive procedure} method-generic-function method Return the generic function that @var{method} belongs to. @@ -2409,18 +2312,18 @@ Return an expression that prints to show the definition of method @end deffn @node Miscellaneous Functions -@section Miscellaneous Functions +@subsection Miscellaneous Functions @menu * Administrative Functions:: -* Error Handling:: +* GOOPS Error Handling:: * Object Comparisons:: * Cloning Objects:: * Write and Display:: @end menu @node Administrative Functions -@subsection Administration Functions +@subsubsection Administration Functions This section describes administrative, non-technical GOOPS functions. @@ -2428,8 +2331,8 @@ This section describes administrative, non-technical GOOPS functions. Return the current GOOPS version as a string, for example ``0.2''. @end deffn -@node Error Handling -@subsection Error Handling +@node GOOPS Error Handling +@subsubsection Error Handling The procedure @code{goops-error} is called to raise an appropriate error by the default methods of the following generic functions: @@ -2464,7 +2367,7 @@ as done by @code{scm-error}. @end deffn @node Object Comparisons -@subsection Object Comparisons +@subsubsection Object Comparisons @deffn generic eqv? @deffnx method eqv? ((x <top>) (y <top>)) @@ -2493,7 +2396,7 @@ and the Guile reference manual. @end deffn @node Cloning Objects -@subsection Cloning Objects +@subsubsection Cloning Objects @deffn generic shallow-clone @deffnx method shallow-clone (self <object>) @@ -2514,7 +2417,7 @@ or by reference. @end deffn @node Write and Display -@subsection Write and Display +@subsubsection Write and Display @deffn {primitive generic} write object port @deffnx {primitive generic} display object port @@ -2542,8 +2445,8 @@ methods - instances of the class @code{<method>}. as the Guile primitive @code{write} and @code{display} functions. @end deffn -@node MOP Specification, Tutorial, Reference Manual, Top -@chapter MOP Specification +@node MOP Specification +@section MOP Specification For an introduction to metaobjects and the metaobject protocol, see @ref{Metaobjects and the Metaobject Protocol}. @@ -2598,7 +2501,7 @@ what the caller expects to get as the applied method's return value. @end menu @node Class Definition -@section Class Definition +@subsection Class Definition @code{define-class} (syntax) @@ -2731,7 +2634,7 @@ or @code{#:accessor} option. @end itemize @node Instance Creation -@section Instance Creation +@subsection Instance Creation @code{make <class> . @var{initargs}} (method) @@ -2752,13 +2655,13 @@ return value is ignored. @end itemize @node Class Redefinition -@section Class Redefinition +@subsection Class Redefinition The default @code{class-redefinition} method, specialized for classes with the default metaclass @code{<class>}, has the following internal protocol. -@code{class-redefinition @var{(old <class>)} @var{(new <class>)}} +@code{class-redefinition (@var{old <class>}) (@var{new <class>})} (method) @itemize @bullet @@ -2797,7 +2700,7 @@ to the modified instance, and initializes new slots, as described in generic function invocation that can be used to customize the instance update algorithm. -@code{change-class @var{(old-instance <object>)} @var{(new <class>)}} (method) +@code{change-class (@var{old-instance <object>}) (@var{new <class>})} (method) @itemize @bullet @item @@ -2814,7 +2717,7 @@ nothing. @end itemize @node Method Definition -@section Method Definition +@subsection Method Definition @code{define-method} (syntax) @@ -2842,7 +2745,7 @@ theoretically handle adding methods to further types of target. @end itemize @node Generic Function Invocation -@section Generic Function Invocation +@subsection Generic Function Invocation [ *fixme* Description required here. ] @@ -2885,21 +2788,3 @@ theoretically handle adding methods to further types of target. @item @code{no-next-method} @end itemize - -@node Tutorial, Concept Index, MOP Specification, Top -@chapter Tutorial -@include goops-tutorial.texi - -@node Concept Index, Function and Variable Index, Tutorial, Top -@unnumberedsec Concept Index - -@printindex cp - -@node Function and Variable Index, , Concept Index, Top -@unnumberedsec Function and Variable Index - -@printindex fn - -@summarycontents -@contents -@bye diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi index a67589915..332be361b 100644 --- a/doc/ref/guile.texi +++ b/doc/ref/guile.texi @@ -4,22 +4,21 @@ @setfilename guile.info @settitle Guile Reference Manual @set guile -@set MANUAL-EDITION 1.1 +@set MANUAL-REVISION 1 @c %**end of header @include version.texi @include lib-version.texi +@include effective-version.texi @copying -This reference manual documents Guile, GNU's Ubiquitous Intelligent -Language for Extensions. This is edition @value{MANUAL-EDITION} -corresponding to Guile @value{VERSION}. +This manual documents Guile version @value{VERSION}. -Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005 Free +Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2009 Free Software Foundation. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or -any later version published by the Free Software Foundation; with the +any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Text ``You are free to copy and modify this GNU Manual.''. A copy of the license is included in the @@ -137,7 +136,7 @@ x @sp 10 @comment The title is printed in a large font. @title Guile Reference Manual -@subtitle Edition @value{MANUAL-EDITION}, for use with Guile @value{VERSION} +@subtitle Edition @value{EDITION}, revision @value{MANUAL-REVISION}, for use with Guile @value{VERSION} @c @subtitle $Id: guile.texi,v 1.49 2008-03-19 22:51:23 ossau Exp $ @c See preface.texi for the list of authors @@ -177,6 +176,8 @@ x * Guile Modules:: +* GOOPS:: + * Guile Implementation:: * Autoconf Support:: @@ -365,6 +366,8 @@ available through both Scheme and C interfaces. @include scsh.texi @include scheme-debugging.texi +@include goops.texi + @node Guile Implementation @chapter Guile Implementation diff --git a/doc/goops/hierarchy.eps b/doc/ref/hierarchy.eps index 7b1a98605..7b1a98605 100644 --- a/doc/goops/hierarchy.eps +++ b/doc/ref/hierarchy.eps diff --git a/doc/goops/hierarchy.pdf b/doc/ref/hierarchy.pdf index 3a19ba4eb..3a19ba4eb 100644 --- a/doc/goops/hierarchy.pdf +++ b/doc/ref/hierarchy.pdf diff --git a/doc/goops/hierarchy.png b/doc/ref/hierarchy.png Binary files differindex 46f58b051..46f58b051 100644 --- a/doc/goops/hierarchy.png +++ b/doc/ref/hierarchy.png diff --git a/doc/goops/hierarchy.txt b/doc/ref/hierarchy.txt index c7992df7b..c7992df7b 100644 --- a/doc/goops/hierarchy.txt +++ b/doc/ref/hierarchy.txt diff --git a/doc/ref/intro.texi b/doc/ref/intro.texi index b0c4c1263..7e248e0e8 100644 --- a/doc/ref/intro.texi +++ b/doc/ref/intro.texi @@ -80,6 +80,7 @@ To unbundle Guile use the instruction zcat guile-@value{VERSION}.tar.gz | tar xvf - @end example +@noindent which will create a directory called @file{guile-@value{VERSION}} with all the sources. You can look at the file @file{INSTALL} for detailed instructions on how to build and install Guile, but you should be able @@ -93,7 +94,7 @@ make install @end example This will install the Guile executable @file{guile}, the Guile library -@file{-lguile} and various associated header files and support +@file{libguile} and various associated header files and support libraries. It will also install the Guile tutorial and reference manual. @@ -101,14 +102,14 @@ manual. Since this manual frequently refers to the Scheme ``standard'', also known as R5RS, or the -@iftex +@tex ``Revised$^5$ Report on the Algorithmic Language Scheme'', -@end iftex +@end tex @ifnottex ``Revised^5 Report on the Algorithmic Language Scheme'', @end ifnottex -we have included the report in the Guile distribution; -@xref{Top, , Introduction, r5rs, Revised(5) Report on the Algorithmic +we have included the report in the Guile distribution; see +@ref{Top, , Introduction, r5rs, Revised(5) Report on the Algorithmic Language Scheme}. This will also be installed in your info directory. @@ -471,11 +472,12 @@ You can get the version number by invoking the command @example $ guile --version Guile 1.9.0 -Copyright (c) 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation +Copyright (c) 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004, +2005, 2006, 2007, 2008, 2009 Free Software Foundation Guile may be distributed under the terms of the GNU Lesser General Public Licence. For details, see the files `COPYING.LESSER' and -`COPYING', which are included in the Guile distribution. There is no -warranty, to the extent permitted by law. +`COPYING', which are included in the Guile distribution. There is +no warranty, to the extent permitted by law. @end example @item diff --git a/doc/ref/libguile-extensions.texi b/doc/ref/libguile-extensions.texi index 77762b5c5..78871c6ca 100644 --- a/doc/ref/libguile-extensions.texi +++ b/doc/ref/libguile-extensions.texi @@ -94,11 +94,11 @@ we are going to call the function @code{init_bessel} which will make @file{.so} when invoking @code{load-extension}. The right extension for the host platform will be provided automatically. -@smalllisp +@lisp (load-extension "libguile-bessel" "init_bessel") (j0 2) @result{} 0.223890779141236 -@end smalllisp +@end lisp For this to work, @code{load-extension} must be able to find @file{libguile-bessel}, of course. It will look in the places that diff --git a/doc/ref/libguile-linking.texi b/doc/ref/libguile-linking.texi index 8869c46d5..72b59bbba 100644 --- a/doc/ref/libguile-linking.texi +++ b/doc/ref/libguile-linking.texi @@ -173,7 +173,8 @@ creating ./config.status creating Makefile $ make gcc -c -I/usr/local/include simple-guile.c -gcc simple-guile.o -L/usr/local/lib -lguile -lqthreads -lpthread -lm -o simple-guile +gcc simple-guile.o -L/usr/local/lib -lguile -lqthreads -lpthread -lm + -o simple-guile $ ./simple-guile guile> (+ 1 2 3) 6 diff --git a/doc/ref/libguile-smobs.texi b/doc/ref/libguile-smobs.texi index 09b5446cd..738809d7a 100644 --- a/doc/ref/libguile-smobs.texi +++ b/doc/ref/libguile-smobs.texi @@ -28,7 +28,7 @@ datatypes described here.) @menu * Describing a New Type:: -* Creating Instances:: +* Creating Smob Instances:: * Type checking:: * Garbage Collecting Smobs:: * Garbage Collecting Simple Smobs:: @@ -132,8 +132,8 @@ init_image_type (void) @end example -@node Creating Instances -@subsection Creating Instances +@node Creating Smob Instances +@subsection Creating Smob Instances Normally, smobs can have one @emph{immediate} word of data. This word stores either a pointer to an additional memory block that holds the @@ -211,7 +211,8 @@ make_image (SCM name, SCM s_width, SCM s_height) /* Step 1: Allocate the memory block. */ - image = (struct image *) scm_gc_malloc (sizeof (struct image), "image"); + image = (struct image *) + scm_gc_malloc (sizeof (struct image), "image"); /* Step 2: Initialize it with straight code. */ @@ -228,7 +229,8 @@ make_image (SCM name, SCM s_width, SCM s_height) /* Step 4: Finish the initialization. */ image->name = name; - image->pixels = scm_gc_malloc (width * height, "image pixels"); + image->pixels = + scm_gc_malloc (width * height, "image pixels"); return smob; @} @@ -404,7 +406,9 @@ free_image (SCM image_smob) @{ struct image *image = (struct image *) SCM_SMOB_DATA (image_smob); - scm_gc_free (image->pixels, image->width * image->height, "image pixels"); + scm_gc_free (image->pixels, + image->width * image->height, + "image pixels"); scm_gc_free (image, sizeof (struct image), "image"); return 0; @@ -583,7 +587,8 @@ make_image (SCM name, SCM s_width, SCM s_height) /* Step 1: Allocate the memory block. */ - image = (struct image *) scm_gc_malloc (sizeof (struct image), "image"); + image = (struct image *) + scm_gc_malloc (sizeof (struct image), "image"); /* Step 2: Initialize it with straight code. */ @@ -600,7 +605,8 @@ make_image (SCM name, SCM s_width, SCM s_height) /* Step 4: Finish the initialization. */ image->name = name; - image->pixels = scm_gc_malloc (width * height, "image pixels"); + image->pixels = + scm_gc_malloc (width * height, "image pixels"); return smob; @} @@ -642,7 +648,9 @@ free_image (SCM image_smob) @{ struct image *image = (struct image *) SCM_SMOB_DATA (image_smob); - scm_gc_free (image->pixels, image->width * image->height, "image pixels"); + scm_gc_free (image->pixels, + image->width * image->height, + "image pixels"); scm_gc_free (image, sizeof (struct image), "image"); return 0; diff --git a/doc/goops/mop.text b/doc/ref/mop.text index 0180f2c1e..0180f2c1e 100644 --- a/doc/goops/mop.text +++ b/doc/ref/mop.text diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index 2d64919a5..d568af23d 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -2072,9 +2072,9 @@ The following procedures are similar to the @code{popen} and @code{pclose} system routines. The code is in a separate ``popen'' module: -@smalllisp +@lisp (use-modules (ice-9 popen)) -@end smalllisp +@end lisp @findex popen @deffn {Scheme Procedure} open-pipe command mode diff --git a/doc/ref/preface.texi b/doc/ref/preface.texi index 7fa85811b..8552d388b 100644 --- a/doc/ref/preface.texi +++ b/doc/ref/preface.texi @@ -7,12 +7,9 @@ @node Preface @chapter Preface -This reference manual documents Guile, GNU's Ubiquitous Intelligent -Language for Extensions. It describes how to use Guile in many useful -and interesting ways. - -This is edition @value{MANUAL-EDITION} of the reference manual, and -corresponds to Guile version @value{VERSION}. +This manual documents version @value{VERSION} of Guile, GNU's +Ubiquitous Intelligent Language for Extensions. It describes how to +use Guile in many useful and interesting ways. @menu * Manual Layout:: @@ -25,7 +22,7 @@ corresponds to Guile version @value{VERSION}. @node Manual Layout @section Layout of this Manual -The manual is divided into five chapters. +The manual is divided into the following chapters. @table @strong @item Chapter 1: Introduction to Guile @@ -38,7 +35,7 @@ the later parts of the manual. This part also explains how to obtain and install new versions of Guile, and how to report bugs effectively. @item Chapter 2: Programming in Scheme -This part provides an overview over programming in Scheme with Guile. +This part provides an overview of programming in Scheme with Guile. It covers how to invoke the @code{guile} program from the command-line and how to write scripts in Scheme. It also gives an introduction into the basic ideas of Scheme itself and to the various extensions @@ -61,6 +58,10 @@ Describes some important modules, distributed as part of the Guile distribution, that extend the functionality provided by the Guile Scheme core. +@item Chapter 6: GOOPS +Describes GOOPS, an object oriented extension to Guile that provides +classes, multiple inheritance and generic functions. + @end table @@ -72,7 +73,7 @@ We use some conventions in this manual. @itemize @bullet @item -For some procedures, notably type predicates, we use @dfn{iff} to mean +For some procedures, notably type predicates, we use ``iff'' to mean ``if and only if''. The construct is usually something like: `Return @var{val} iff @var{condition}', where @var{val} is usually ``@nicode{#t}'' or ``non-@nicode{#f}''. This typically means that @@ -144,6 +145,9 @@ filling out a lot of the documentation of Scheme data types, control mechanisms and procedures. In addition, he wrote the documentation for Guile's SRFI modules and modules associated with the Guile REPL. +The chapter on GOOPS was written by Christian Lynbech, Mikael +Djurfeldt and Neil Jerram. + @node Guile License @section The Guile License @cindex copying @@ -179,7 +183,7 @@ C code linking to the Guile readline module is subject to the terms of that module. Basically such code must be published on Free terms. Scheme level code written to be run by Guile (but not derived from -Guile itself) is not resticted in any way, and may be published on any +Guile itself) is not restricted in any way, and may be published on any terms. We encourage authors to publish on Free terms. You must be aware there is no warranty whatsoever for Guile. This is diff --git a/doc/ref/scheme-debugging.texi b/doc/ref/scheme-debugging.texi index 07511263b..bcd9f2df3 100644 --- a/doc/ref/scheme-debugging.texi +++ b/doc/ref/scheme-debugging.texi @@ -14,9 +14,9 @@ call to that procedure is reported to the user during a program run. The idea is that you can mark a collection of procedures for tracing, and Guile will subsequently print out a line of the form -@smalllisp +@lisp | | [@var{procedure} @var{args} @dots{}] -@end smalllisp +@end lisp whenever a marked procedure is about to be applied to its arguments. This can help a programmer determine whether a function is being called @@ -27,7 +27,7 @@ how the traced applications are or are not tail recursive with respect to each other. Thus, a trace of a non-tail recursive factorial implementation looks like this: -@smalllisp +@lisp [fact1 4] | [fact1 3] | | [fact1 2] @@ -38,11 +38,11 @@ implementation looks like this: | | 2 | 6 24 -@end smalllisp +@end lisp While a typical tail recursive implementation would look more like this: -@smalllisp +@lisp [fact2 4] [facti 1 4] [facti 4 3] @@ -50,7 +50,7 @@ While a typical tail recursive implementation would look more like this: [facti 24 1] [facti 24 0] 24 -@end smalllisp +@end lisp @deffn {Scheme Procedure} trace procedure Enable tracing for @code{procedure}. While a program is being run, diff --git a/doc/ref/scheme-ideas.texi b/doc/ref/scheme-ideas.texi index 38b105b94..55093cf92 100644 --- a/doc/ref/scheme-ideas.texi +++ b/doc/ref/scheme-ideas.texi @@ -390,7 +390,11 @@ this: @noindent This is a valid procedure invocation expression, and its result is the -string @code{"Name=FSF:Address=Cambridge"}. +string: + +@lisp +"Name=FSF:Address=Cambridge" +@end lisp It is more common, though, to store the procedure value in a variable --- diff --git a/doc/ref/scsh.texi b/doc/ref/scsh.texi index 0f869ecd7..b1af1a443 100644 --- a/doc/ref/scsh.texi +++ b/doc/ref/scsh.texi @@ -19,8 +19,8 @@ For information about scsh see The closest emulation of scsh can be obtained by running: -@smalllisp +@lisp (load-from-path "scsh/init") -@end smalllisp +@end lisp See the USAGE file supplied with guile-scsh for more details. diff --git a/doc/ref/slib.texi b/doc/ref/slib.texi index fc8f91933..d3357c97f 100644 --- a/doc/ref/slib.texi +++ b/doc/ref/slib.texi @@ -4,7 +4,6 @@ @c Free Software Foundation, Inc. @c See the file guile.texi for copying conditions. -@page @node SLIB @section SLIB @cindex SLIB @@ -12,9 +11,9 @@ Before the SLIB facilities can be used, the following Scheme expression must be executed: -@smalllisp +@lisp (use-modules (ice-9 slib)) -@end smalllisp +@end lisp @findex require @code{require} can then be used in the usual way (@pxref{Require,,, @@ -64,7 +63,7 @@ Alternatively, you can create a symlink in the Guile directory to SLIB, e.g.: @example -ln -s /usr/local/lib/slib /usr/local/share/guile/1.8/slib +ln -s /usr/local/lib/slib /usr/local/share/guile/@value{EFFECTIVE-VERSION}/slib @end example @item @@ -78,7 +77,7 @@ guile> (quit) @end example The catalog data should now be in -@file{/usr/local/share/guile/1.8/slibcat}. +@file{/usr/local/share/guile/@value{EFFECTIVE-VERSION}/slibcat}. If instead you get an error such as: @@ -104,11 +103,11 @@ It is usually installed as an extra package in SLIB. You can use Guile's interface to SLIB to invoke Jacal: -@smalllisp +@lisp (use-modules (ice-9 slib)) (slib:load "math") (math) -@end smalllisp +@end lisp @noindent For complete documentation on Jacal, please read the Jacal manual. If diff --git a/doc/ref/tools.texi b/doc/ref/tools.texi index f2116dd71..8b0d3a3bb 100644 --- a/doc/ref/tools.texi +++ b/doc/ref/tools.texi @@ -232,8 +232,8 @@ is a expression suitable for initializing a new variable. For procedures, you can use @code{SCM_DEFINE} for most purposes. Use @code{SCM_PROC} along with @code{SCM_REGISTER_PROC} when you don't want to be bothered with docstrings. Use @code{SCM_GPROC} for generic -functions (@pxref{Creating Generic Functions,,, goops, GOOPS}). All -procedures are declared with return type @code{SCM}. +functions (@pxref{Creating Generic Functions}). All procedures are +declared with return type @code{SCM}. For everything else, use the appropriate macro (@code{SCM_SYMBOL} for symbols, and so on). Without "_GLOBAL_", the declarations are @@ -364,7 +364,7 @@ of the form: @example (define-module (scripts PROGRAM) - :export (PROGRAM)) + #:export (PROGRAM)) @end example Feel free to export other definitions useful in the module context. diff --git a/doc/ref/vm.texi b/doc/ref/vm.texi index 04a3b7949..43b265596 100644 --- a/doc/ref/vm.texi +++ b/doc/ref/vm.texi @@ -308,19 +308,19 @@ scheme@@(guile-user)> (define (foo a) (lambda (b) (list foo a b))) scheme@@(guile-user)> ,x foo Disassembly of #<program foo (a)>: - 0 (object-ref 1) ;; #<program b7e478b0 at <unknown port>:0:16 (b)> - 2 (local-ref 0) ;; `a' (arg) - 4 (vector 0 1) ;; 1 element + 0 (object-ref 1) ;; #<program b7e478b0 at <unknown port>:0:16 (b)> + 2 (local-ref 0) ;; `a' (arg) + 4 (vector 0 1) ;; 1 element 7 (make-closure) 8 (return) ---------------------------------------- Disassembly of #<program b7e478b0 at <unknown port>:0:16 (b)>: - 0 (toplevel-ref 1) ;; `foo' - 2 (free-ref 0) ;; (closure variable) - 4 (local-ref 0) ;; `b' (arg) - 6 (list 0 3) ;; 3 elements at (unknown file):0:28 + 0 (toplevel-ref 1) ;; `foo' + 2 (free-ref 0) ;; (closure variable) + 4 (local-ref 0) ;; `b' (arg) + 6 (list 0 3) ;; 3 elements at (unknown file):0:28 9 (return) @end smallexample |