Changeset 10415 in project


Ignore:
Timestamp:
04/10/08 22:06:43 (12 years ago)
Author:
elf
Message:

branch for testing some core reductions

Location:
chicken/branches/elf
Files:
332 added
64 edited

Legend:

Unmodified
Added
Removed
  • chicken/branches/elf/branch-24012008/Makefile

    r7215 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
    3426
    3527
     
    5143        @echo "  $(MAKE) PLATFORM=solaris"
    5244        @echo "  $(MAKE) PLATFORM=cross-linux-mingw"
     45        @echo "  $(MAKE) PLATFORM=msvc"
    5346        @echo ""
    5447        @echo "For more information, consult the README file."
    5548        @exit 1
     49dist:
     50        csi -s scripts/makedist.scm
    5651else
    5752all:
     
    7368fullcheck:
    7469        $(MAKE) -f Makefile.$(PLATFORM) fullcheck
    75 dist:
    76         $(MAKE) -f Makefile.$(PLATFORM) distfiles
    77         csi -s misc/makedist.scm
    7870libs:
    7971        $(MAKE) -f Makefile.$(PLATFORM) libs
  • chicken/branches/elf/branch-24012008/Makefile.bsd

    r6569 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
    3426
    3527
     
    5951
    6052chicken-config.h: chicken-defaults.h
    61         echo "#define HAVE_DIRENT_H 1" >>$@
     53        echo "#define HAVE_DIRENT_H 1" >$@
    6254        echo "#define HAVE_DLFCN_H 1" >>$@
    6355        echo "#define HAVE_INTTYPES_H 1" >>$@
  • chicken/branches/elf/branch-24012008/Makefile.cross-linux-mingw

    r7331 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
    3426
    3527
     
    9183
    9284chicken-config.h: chicken-defaults.h
    93         echo "#define HAVE_DIRENT_H 1" >>$@
     85        echo "#define HAVE_DIRENT_H 1" >$@
    9486        echo "#define HAVE_INTTYPES_H 1" >>$@
    9587        echo "#define HAVE_LIMITS_H 1" >>$@
  • chicken/branches/elf/branch-24012008/Makefile.cygwin

    r7077 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
    3426
    3527
     
    9082include defaults.make
    9183
    92 chicken-config.h: chicken-defaults.h
     84chicken-config.h: chicken-defaults.h buildsvnrevision
     85        echo "#define C_SVN_REVISION $(shell cat buildsvnrevision)" >$@
    9386        echo "#define HAVE_DIRENT_H 1" >>$@
    9487        echo "#define HAVE_INTTYPES_H 1" >>$@
  • chicken/branches/elf/branch-24012008/Makefile.linux

    r7325 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
    3426
    3527
     
    6254
    6355chicken-config.h: chicken-defaults.h
    64         echo "#define HAVE_DIRENT_H 1" >>$@
     56        echo "#define HAVE_DIRENT_H 1" >$@
    6557        echo "#define HAVE_DLFCN_H 1" >>$@
    6658        echo "#define HAVE_INTTYPES_H 1" >>$@
  • chicken/branches/elf/branch-24012008/Makefile.macosx

    r7773 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
     26
    3427
    3528# platform configuration
     
    6760
    6861chicken-config.h: chicken-defaults.h
    69         echo "#define HAVE_DIRENT_H 1" >>$@
     62        echo "#define HAVE_DIRENT_H 1" >$@
    7063        echo "#define HAVE_DLFCN_H 1" >>$@
    7164        echo "#define HAVE_INTTYPES_H 1" >>$@
  • chicken/branches/elf/branch-24012008/Makefile.mingw

    r7180 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
    3426
    3527
     
    4032HACKED_APPLY = 1
    4133WINDOWS = 1
     34NO_UNIX_SHELL = 1
    4235
    4336# file extensions
     
    8982
    9083chicken-config.h: chicken-defaults.h
    91         echo #define HAVE_DIRENT_H 1 >>$@
     84        echo #define HAVE_DIRENT_H 1 >$@
    9285        echo #define HAVE_INTTYPES_H 1 >>$@
    9386        echo #define HAVE_LIMITS_H 1 >>$@
     
    210203        echo # define C_TARGET_STATIC_LIB_HOME "$(TARGET_PREFIX)/lib" >>$@
    211204        echo #endif >>$@
     205        echo #ifndef C_BINARY_VERSION >>$@
     206        echo # define C_BINARY_VERSION $(BINARYVERSION) >>$@
     207        echo #endif >>$@
    212208
    213209include rules.make
  • chicken/branches/elf/branch-24012008/Makefile.mingw-msys

    r7180 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
    3426
    3527
     
    8678
    8779chicken-config.h: chicken-defaults.h
    88         echo "#define HAVE_DIRENT_H 1" >>$@
     80        echo "#define HAVE_DIRENT_H 1" >$@
    8981        echo "#define HAVE_INTTYPES_H 1" >>$@
    9082        echo "#define HAVE_LIMITS_H 1" >>$@
  • chicken/branches/elf/branch-24012008/Makefile.solaris

    r6569 r10415  
    22#
    33# Copyright (c) 2007, Felix L. Winkelmann
     4# Copyright (c) 2008, The Chicken Team
    45# All rights reserved.
    56#
     
    2324# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425# POSSIBILITY OF SUCH DAMAGE.
    25 #
    26 # Send bugs, suggestions and ideas to:
    27 #
    28 # felix@call-with-current-continuation.org
    29 #
    30 # Felix L. Winkelmann
    31 # Unter den Gleichen 1
    32 # 37130 Gleichen
    33 # Germany
    3426
    3527
     
    5951
    6052chicken-config.h: chicken-defaults.h
    61         echo "#define HAVE_DIRENT_H 1" >>$@
     53        echo "#define HAVE_DIRENT_H 1" >$@
    6254        echo "#define HAVE_DLFCN_H 1" >>$@
    6355        echo "#define HAVE_INTTYPES_H 1" >>$@
  • chicken/branches/elf/branch-24012008/NEWS

    r7864 r10415  
    1 3.0.0rc1
     13.1.2
     2
     3- unit utils: added file-copy and file-move (request by the einit team)
     4
     53.1.1
     6
     7- unit srfi-69: added hash-table-clear!
     8- unit srfi-69: new
     9- unit extras: moved SRFI 69 to unit srfi-69
     10
     113.1.0
     12
     13- svnrevision.sh - cleaned logic to prevent invalid error message
     14- csc - fixed bug preventing static linking of executables (build order issues)
     15- unit regex: PCRE 7.6
     16- unit regex: avoid string copy in regex matching [Jim Ursetto]
     17- chicken-setup: eggs are downloaded to and compiled in a temporary
     18  directory determined by CHICKEN_TMPDIR or TMPDIR environment
     19  variables, or by -build-prefix and -download-dir options,
     20  respectively; -destdir option is replaced with -install-prefix.
     21- unit tcp: use of offset into string rather than substring for faster
     22  socket write [Jim Ursetto]
     23- MSVC can now be used to build the system, when standard UNIX tools (like
     24  MSYS) are available [Many thanks to Ashley]
     25- unit library: added "flonum-print-precision" for changing the default of
     26  16
     27- unit posix: create-directory can now handle DOS drive letters
     28  in the given path
     29- unit posix: added stat- predicates for file types
     30- unit posix: added strftime format string support to "time->string"
     31- unit posix: added "string->time", which takes a strptime format string
     32  (Unix only)
     33- unit extras: added "left-section", "right-section", "none?", "always?",
     34  and "never?"
     35- unit extras: added "hash-table-merge", "hash-table-map",
     36  "hash-table-for-each", and extended "make-hash-table" with minimum/maximum
     37  load & initial value
     38- unit extras: added "eq?-hash", "eqv?-hash", "equal?-hash", "number-hash",
     39  "symbol-hash", "keyword-hash", "##sys#number-hash-hook", and
     40  "hash-by-identity" as a synonym for "eq?-hash"
     41
     423.0.0
    243
    344- upgraded scheme-complete.el to version 0.6 [Thanks to Alex Shinn]
  • chicken/branches/elf/branch-24012008/README

    r7916 r10415  
    33  (c)2000-2008 Felix L. Winkelmann
    44
    5   version 3.0.1
     5  version 3.1.2
    66
    77
     
    7171        installed, then pass "CHICKEN=<chicken-executable>" to the
    7272        "make" invocation to override this setting. "CHICKEN" defaults
    73         to defaults to "$PREFIX/bin/chicken".
     73        to "$PREFIX/bin/chicken".
    7474
    7575        If you do not have a "chicken" binary installed, enter
     
    7979        which will unpack a tarball containing precompiled C sources
    8080        that are recent enough to generate the current version. After
    81         building a statically linked "chicken" executable, the system
    82         is rebuilt using the static compiler.
     81        building a statically linked compiler executable (named
     82        "chicken-boot") all *.scm files are marked for rebuilt. By
     83        passing "CHICKEN=./chicken-boot" to "make", you can force
     84        using this bootstrapped compiler to build the system.
    8385
    8486        The build may show errors when creating the info(1)
     
    111113          Build only static versions of the runtime library, compiler
    112114          and interpreter. `chicken-setup' will not be generated,
    113           as it is mostly unless compiled code can be loaded.
     115          as it is mostly useless unless compiled code can be loaded.
    114116
    115117        SYMBOLGC=1
     
    251253        - For Mac OS X, Chicken requires libdl, for loading compiled
    252254          code dynamically. This library is available on Mac OS X 10.4
    253           (Tiger) by default. For older version you can find it here:
     255          (Tiger) by default. For older versions you can find it here:
    254256
    255257            http://www.opendarwin.org/projects/dlcompat
     
    257259        - On Mac OS X, Chicken and its eggs can be built as universal
    258260          binaries which will work on either Intel or PowerPC.
    259 
     261          To build on Tiger (10.4):
     262
     263            make PLATFORM=macosx ARCH=universal
     264
     265          On Leopard (10.5), an extra step is required before `make':
     266
     267            export MACOSX_DEPLOYMENT_TARGET=10.4
    260268            make PLATFORM=macosx ARCH=universal
    261269
    262270        - On Mac OS X, Chicken can be built in 64-bit mode on Intel
    263271          Core 2 Duo systems--basically, most recent machines.  The default
    264           is 32-bit mode.  To enable 64-bit mode, invoke `make` thusly:
     272          is 32-bit mode.  To enable 64-bit mode, invoke `make' thusly:
    265273
    266274            make PLATFORM=macosx ARCH=x86-64
    267275
    268         - On Windows, only mingw32 <http://mingw.sourceforge.net/> and
    269           Cygwin is supported (Microsoft Visual Studio is
    270           NOT). Makefiles for mingw under MSYS and Windows shell are
    271           provided (`Makefile.mingw-msys' and `Makefile.mingw').
    272          
     276        - On Windows, mingw32, <http://mingw.sourceforge.net/>,
     277          Cygwin, and Visual C/C++ (PLATFORM=msvc) are supported.
     278          Makefiles for mingw under MSYS and Windows shell are provided
     279          (`Makefile.mingw-msys' and `Makefile.mingw').
     280
     281        - When installing under the mingw-msys platform, PREFIX must be an
     282          absolute path name (i.e. it must include the drive letter).
     283
    273284        - Cygwin will not be able to find the chicken shared libraries
    274285          until Windows is rebooted.
     
    282293          warnings are bogus and can be ignored.
    283294
     295        - The Visual C build requires GNU make and other POSIX
     296          utilities.  Both cygwin and msys (with the Developer's
     297          Toolkit) have the necessary utilities. When setting PREFIX,
     298          use forward slashes:
     299
     300          make PLATFORM=msvc PREFIX=c:/development/chicken
     301
     302          The build has been tested with Visual Studio 2003 and 2008.  If
     303          you are able to build Chicken with other versions, please let
     304          us know.
     305
     306          The following additional issues apply when using Chicken with
     307          Visual C:
     308
     309          - Add the /DPIC flag when compiling your source files.  Otherwise
     310            you will encounter undefined symbols when linking.  Note that csc
     311            does this automatically for dlls but NOT for programs.
     312
     313          - csc generates dynamics libraries with a .so extension, not .dll.
    284314
    285315 6. Emacs support:
     
    335365        If you have any more questions or problems (even the slightest
    336366        problems, or the most stupid questions), then please subscribe
    337         to the "chicken-users" mailing list or contact me at:
    338 
    339         <felix@call-with-current-continuation.org>
     367        to the "chicken-users" mailing list and ask for help. It will
     368        be answered.
    340369
    341370
  • chicken/branches/elf/branch-24012008/apply-hack.ppc.darwin.s

    r5861 r10415  
    22;
    33; Copyright (c) 2007, Felix L. Winkelmann
     4; Copyright (c) 2008 The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426*/
    3527
  • chicken/branches/elf/branch-24012008/apply-hack.ppc.sysv.s

    r5861 r10415  
    22;
    33; Copyright (c) 2007, Felix L. Winkelmann
    4 ; All rights reserved.
     4; Copyright (c) 2008, The Chicken Team
     5; All rights reserved.         
    56;
    67; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426*/
    3527
  • chicken/branches/elf/branch-24012008/apply-hack.x86-64.s

    r7044 r10415  
    22;
    33; Copyright (c) 2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426*/
    3527
  • chicken/branches/elf/branch-24012008/apply-hack.x86.s

    r5526 r10415  
    22;
    33; Copyright (c) 2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426*/
    3527
  • chicken/branches/elf/branch-24012008/banner.scm

    r7776 r10415  
    22
    33CHICKEN
     4(c)2008 The Chicken Team
     5(c)2000-2007 Felix L. Winkelmann
    46
    57EOF
    68)
    7 
    8 (define-constant +copyright+ "(c)2000-2008 Felix L. Winkelmann")
  • chicken/branches/elf/branch-24012008/batch-driver.scm

    r7274 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426
    3527
     
    381373           (unless quiet
    382374             (print-version #t)
    383              (display "\n\nEnter \"chicken -help\" for information on how to use it.\n") ) )
     375             (display "\nEnter \"chicken -help\" for information on how to use it.\n") ) )
    384376          (else
    385377
     
    498490                    [proc (user-pass-2)] )
    499491               (when (debugging 'M "; requirements:")
    500                  (pretty-print (hash-table->alist file-requirements)))
     492                 (pretty-print (##sys#hash-table->alist file-requirements)))
    501493               (when proc
    502494                 (when verbose (printf "Secondary user pass...~%"))
  • chicken/branches/elf/branch-24012008/buildversion

    r7916 r10415  
    1 3.0.1
     13.1.2
  • chicken/branches/elf/branch-24012008/c-backend.scm

    r7784 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426
    3527
     
    507499                ((>= n llen))
    508500              (gen #\, (char->integer (string-ref ll n))) )
    509             (do ((n (remainder llen 8) (sub1 n))) ; fill up with zeros to align following entry
     501            (do ((n (- (bitwise-and #xfffff8 (+ llen 7)) llen) (sub1 n))) ; fill up with zeros to align following entry
    510502                ((zero? n))
    511503              (gen ",0") )
     
    696688            ((null? lit)
    697689             (gen #t to "=C_SCHEME_END_OF_LIST;") )
    698             ((##sys#immediate? lit) (bad-literal lit))
    699             ((##core#inline "C_lambdainfop" lit))
    700             (else
     690            ((and (not (##sys#immediate? lit))
     691                  (##core#inline "C_lambdainfop" lit)))
     692            ((or (fixnum? lit) (not (##sys#immediate? lit)))
    701693             (gen #t to "=C_decode_literal(C_heaptop,")
    702694             (gen-string-constant (encode-literal lit))
    703              (gen ");") ) ) )
     695             (gen ");") )
     696            (else (bad-literal lit))))
    704697
    705698    (define (gen-string-constant str)
     
    13641357         ((eof-object? lit) "\xff\x3e")
    13651358         ((eq? (void) lit) "\xff\x1e")
    1366          ((and (fixnum? lit) (not (big-fixnum? lit)))
    1367           (string-append
    1368            "\xff\x01"
    1369            (string (integer->char (bitwise-and #xff (arithmetic-shift lit -24)))
    1370                    (integer->char (bitwise-and #xff (arithmetic-shift lit -16)))
    1371                    (integer->char (bitwise-and #xff (arithmetic-shift lit -8)))
    1372                    (integer->char (bitwise-and #xff lit)) ) ) )
     1359         ((fixnum? lit)
     1360          (if (not (big-fixnum? lit))
     1361              (string-append
     1362               "\xff\x01"
     1363               (string (integer->char (bitwise-and #xff (arithmetic-shift lit -24)))
     1364                       (integer->char (bitwise-and #xff (arithmetic-shift lit -16)))
     1365                       (integer->char (bitwise-and #xff (arithmetic-shift lit -8)))
     1366                       (integer->char (bitwise-and #xff lit)) ) )
     1367              (string-append "\xff\x55" (number->string lit) "\x00") ) )
    13731368         ((number? lit)
    13741369          (string-append "\x55" (number->string lit) "\x00") )
  • chicken/branches/elf/branch-24012008/c-platform.scm

    r7167 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426
    3527
     
    108100       ##sys#profile-entry ##sys#profile-exit) ) ) )
    109101
    110 (define units-used-by-default '(library eval extras))
     102(define units-used-by-default '(library eval extras srfi-69)) ;*** remove srfi-69 on next major release
    111103(define words-per-flonum 4)
    112104(define parameter-limit 1024)
  • chicken/branches/elf/branch-24012008/chicken-bug.1

    r7036 r10415  
    5757
    5858.SH AUTHOR
    59 .I chicken-bug
    60 was written by Felix L. Winkelmann (felix@call-with-current-continuation.org).
     59Felix L. Winkelmann (felix@call-with-current-continuation.org)
     60and The Chicken Team.
    6161
    6262.SH SEE ALSO
  • chicken/branches/elf/branch-24012008/chicken-bug.scm

    r7864 r10415  
    11;;;; chicken-bug.scm - Bug report-generator
     2;
     3; Copyright (c) 2008, The Chicken Team
     4; All rights reserved.
     5;
     6; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
     7; conditions are met:
     8;
     9;   Redistributions of source code must retain the above copyright notice, this list of conditions and the following
     10;     disclaimer.
     11;   Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
     12;     disclaimer in the documentation and/or other materials provided with the distribution.
     13;   Neither the name of the author nor the names of its contributors may be used to endorse or promote
     14;     products derived from this software without specific prior written permission.
     15;
     16; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
     17; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
     18; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
     19; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     23; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     24; POSSIBILITY OF SUCH DAMAGE.
    225
    326
     
    1942
    2043(define-constant +fallbackdestinations+
    21   "chicken-janitors@nongnu.org\nchicken-hackers@nongnu.org\nchicken-users@nongnu.org\nfelix@call-with-current-continuation.org")
     44  "chicken-janitors@nongnu.org\nchicken-hackers@nongnu.org\nchicken-users@nongnu.org")
    2245
    2346(define-constant +destination+ "chicken-janitors@nongnu.org")
  • chicken/branches/elf/branch-24012008/chicken-ffi-macros.scm

    r6839 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426
    3527
  • chicken/branches/elf/branch-24012008/chicken-more-macros.scm

    r7915 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426
    3527
     
    377369                 (let ([b (##sys#slot bs 0)]
    378370                       [bs2 (##sys#slot bs 1)] )
    379                    (cond [(not (pair? b)) `(if ,b ,(fold bs2) #f)]
     371                   (cond [(not-pair? b) `(if ,b ,(fold bs2) #f)]
    380372                         [(null? (##sys#slot b 1)) `(if ,(##sys#slot b 0) ,(fold bs2) #f)]
    381373                         [else
     
    634626
    635627(define-macro (case-lambda . clauses)
    636     (let ((args   (gensym))
    637           (tblv   (gensym))
    638           (cntv   (gensym)))
    639         (define ptbl
    640             (let loop ((l   clauses)
    641                        (m   #f)
    642                        (e   (lambda m    (error 'case-lambda (apply conc m))))
    643                        (w   (lambda m    (##sys#warn (apply conc m))))
    644                        (r   '()))
    645                 (cond ((null? l)
    646                           (if (null? r)
    647                               (e "not enough arguments: no clauses given.")
    648                               (map
    649                                   (lambda (x)
    650                                       `(cons ,(car x) ,(caddr x)))
    651                                   (reverse r))))
    652                       ((and (list? (car l)) (> (length (car l)) 1))
    653                           (let* ((la   (caar l))
    654                                  (ld   (cdar l))
    655                                  (al   (car l))
    656                                  (ll   (or (and (pair? la) (length la)) 0))
    657                                  (ck   `(cons ,ll ,(not (list? la))))
    658                                  (cp   `(lambda ,la ,@ld)))
    659                               (cond ((symbol? la)
    660                                         (or (null? (cdr l))
    661                                             (w "rest clause found with "
    662                                                (length (cdr l))
    663                                                " following clauses - "
    664                                                "skipping them."))
    665                                         (loop '() 0 e w
    666                                               (cons `(,ck ',al ,cp) r)))
    667                                     ((and (not (pair? la)) (not (null? la)))
    668                                         (e "invalid lambda list: " la))
    669                                     ((and m (fx<= m ll))
    670                                         (w "prior clause with fewer req args "
    671                                            "and rest arg: skipping clause "
    672                                            al)
    673                                         (loop (cdr l) m e w r))
    674                                     ((assoc ck r)
    675                                         (w "prior clause with same signature - "
    676                                            "skipping clause " al)
    677                                         (loop (cdr l) m e w r))
    678                                     ((not (list? la))
    679                                         (loop (cdr l) ll e w
    680                                               (cons `(,ck ',al ,cp) r)))
    681                                     (else
    682                                         (loop (cdr l) m e w
    683                                               (cons `(,ck ',al ,cp) r))))))
    684                       (else
    685                           (e "invalid clause: " (car l))))))
    686         `(lambda ,args
    687             (let loop ((,tblv   (list ,@ptbl))
    688                        (,cntv   (length ,args)))
    689                 (if (null? ,tblv)
    690                     (error 'case-lambda
    691                            (conc "no matching clause in call to case-lambda: "
    692                                  "arity - " ,cntv "  , args - " ,args))
    693                     (if (or (fx= (caaar ,tblv) ,cntv)
    694                             (and (cdaar ,tblv) (fx< (caaar ,tblv) ,cntv)))
    695                         (##sys#apply (cdar ,tblv) ,args)
    696                         (loop (cdr ,tblv) ,cntv)))))))
    697 
     628  (define (genvars n)
     629    (let loop ([i 0])
     630      (if (fx>= i n)
     631          '()
     632          (cons (gensym) (loop (fx+ i 1))) ) ) )
     633  (##sys#check-syntax 'case-lambda clauses '#(_ 0))
     634  (require 'srfi-1)                     ; Urgh...
     635  (let* ((mincount (apply min (map (lambda (c)
     636                                     (##sys#decompose-lambda-list
     637                                      (car c)
     638                                      (lambda (vars argc rest) argc) ) )
     639                                   clauses) ) )
     640         (minvars (genvars mincount))
     641         (rvar (gensym))
     642         (lvar (gensym)) )
     643    `(lambda ,(append minvars rvar)
     644       (let ((,lvar (length ,rvar)))
     645         ,(fold-right
     646           (lambda (c body)
     647             (##sys#decompose-lambda-list
     648              (car c)
     649              (lambda (vars argc rest)
     650                (##sys#check-syntax 'case-lambda (car c) 'lambda-list)
     651                `(if ,(let ([a2 (fx- argc mincount)])
     652                        (if rest
     653                            (if (zero? a2)
     654                                #t
     655                                `(fx>= ,lvar ,a2) )
     656                            `(fx= ,lvar ,a2) ) )
     657                     ,(receive
     658                       (vars1 vars2) (split-at! (take vars argc) mincount)
     659                       (let ((bindings
     660                              (let build ((vars2 vars2) (vrest rvar))
     661                                (if (null? vars2)
     662                                    (cond (rest `(let ((,rest ,vrest)) ,@(cdr c)))
     663                                          ((null? (cddr c)) (cadr c))
     664                                          (else `(let () ,@(cdr c))) )
     665                                    (let ((vrest2 (gensym)))
     666                                      `(let ((,(car vars2) (car ,vrest))
     667                                             (,vrest2 (cdr ,vrest)) )
     668                                         ,(if (pair? (cdr vars2))
     669                                              (build (cdr vars2) vrest2)
     670                                              (build '() vrest2) ) ) ) ) ) ) )
     671                         (if (null? vars1)
     672                             bindings
     673                             `(let ,(map list vars1 minvars) ,bindings) ) ) )
     674                     ,body) ) ) )
     675           '(##core#check (##sys#error (##core#immutable '"no matching clause in call to 'case-lambda' form")))
     676           clauses) ) ) ) )
    698677
    699678
     
    724703
    725704(define-macro (condition-case exp . clauses)
    726   (let* ([exvar (gensym)]
    727          [ccvar (gensym)]
    728          [evar (gensym)]
    729          [elsvar (gensym)]
    730          [elsbod `((##sys#apply ##sys#values ,elsvar))]
    731          [kvar (gensym)] )
     705  (let ([exvar (gensym)]
     706        [kvar (gensym)] )
    732707    (define (parse-clause c)
    733       (let* ([els (and (symbol? (car c)) (eq? 'else (car c)))]
    734              [var (and (symbol? (car c)) (car c))]
     708      (let* ([var (and (symbol? (car c)) (car c))]
    735709             [kinds (if var (cadr c) (car c))]
    736710             [body (if var (cddr c) (cdr c))] )
    737         (if els
    738             (begin
    739                 (set! elsvar kinds)
    740                 (set! elsbod body)
    741                 `(#f   #f))
    742             (if (null? kinds)
    743                 `(else
    744                   ,(if var
    745                        `(let ([,var ,exvar]) (,ccvar (begin ,@body)))
    746                        `(let () (,ccvar (begin ,@body))) ) )
    747                 `((and ,kvar ,@(map (lambda (k) `(memv ',k ,kvar)) kinds))
    748                   ,(if var
    749                        `(let ([,var ,exvar]) (,ccvar (begin ,@body)))
    750                        `(let () (,ccvar (begin ,@body))) ) ) ) ) ) )
    751     `(call-with-current-continuation
    752         (lambda (,ccvar)
    753             (##sys#call-with-values
    754                 (lambda ()
    755                     (handle-exceptions
    756                         ,exvar
    757                         (let ((,kvar   (and (##sys#structure? ,exvar 'condition)
    758                                             (##sys#slot ,exvar 1))))
    759                             (cond ,@(map parse-clause clauses)
    760                                   (else    (##sys#signal ,exvar))))
    761                         ,exp))
    762                 (lambda ,evar
    763                     (##sys#apply (lambda ,elsvar ,@elsbod) ,evar)))))))
     711        (if (null? kinds)
     712            `(else
     713              ,(if var
     714                   `(let ([,var ,exvar]) ,@body)
     715                   `(let () ,@body) ) )
     716            `((and ,kvar ,@(map (lambda (k) `(memv ',k ,kvar)) kinds))
     717              ,(if var
     718                   `(let ([,var ,exvar]) ,@body)
     719                   `(let () ,@body) ) ) ) ) )
     720    `(handle-exceptions ,exvar
     721         (let ([,kvar (and (##sys#structure? ,exvar 'condition) (##sys#slot ,exvar 1))])
     722           (cond ,@(map parse-clause clauses)
     723                 (else (##sys#signal ,exvar)) ) )
     724       ,exp) ) )
    764725
    765726
  • chicken/branches/elf/branch-24012008/chicken-profile.1

    r5945 r10415  
    5555.SH BUGS
    5656Submit bug reports by e-mail to
    57 .I felix@call-with-current-continuation.org
     57.I chicken-janitors@nongnu.org
    5858
    59 .SH AUTHOR
    60 .I csc
    61 was written by Felix L. Winkelmann (felix@call-with-current-continuation.org).
     59.SH AUTHORS
     60Felix L. Winkelmann and the Chicken Team
    6261
    6362.SH SEE ALSO
  • chicken/branches/elf/branch-24012008/chicken-profile.scm

    r6439 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426
    3527
     
    3830  (uses srfi-1
    3931        srfi-13
     32        srfi-69
    4033        posix
    4134        utils))
  • chicken/branches/elf/branch-24012008/chicken-setup.1

    r7334 r10415  
    11.\" dummy line
    2 .TH CHICKEN-SETUP 1 "25 Jan 2004"
     2.TH CHICKEN-SETUP 1 "28 Feb 2008"
    33
    44.SH NAME
     
    5050.SH OPTIONS
    5151
     52.TP
     53.B \-h,\ \-help     
     54Shows a summary of options and exits.
     55
     56.TP
     57.B \-V,\ \-version
     58Shows the version of
     59.I chicken-setup
     60and exits.
     61
     62.TP
     63.B \-release
     64Shows release number of CHICKEN and exits.
     65
     66.TP
     67.BI \-R,\ \-repository \ [PATH]         
     68If
     69.B PATH
     70is not given, prints the location of the extension repository.
     71If
     72.B PATH
     73is given, specifies the location for the extension repository
     74The default repository path is the installation library directory (usually
     75.I /usr/local/lib/chicken
     76, or (if set) the directory given in the environment variable
     77.I CHICKEN\_REPOSITORY
     78
     79.TP
     80.B \-u,\ \-uninstall
     81Removes the given extension from the repository.
     82
     83.TP
     84.BI \-H,\ \-host \ HOSTNAME[:PORT]
     85Specifies alternative host for downloading extensions.
     86.B PORT
     87may be omitted and defaults to 80.
     88
     89.TP
     90.BI \-p,\ \-proxy \ HOSTNAME[:PORT]
     91Connects to server via proxy.
     92.B PORT
     93may be omitted and defaults to 80.
     94
     95.TP
     96.B \-l,\ \-list
     97Lists all installed extensions and exits, or show extension-information
     98of extensions given on the command-line (following this option).
     99
     100.TP
     101.BI \-r,\ \-run \ FILENAME
     102Loads and executes given file.
     103
     104.TP
     105.BI \-P,\ \-program\-path \ [PATH]
     106If
     107.B PATH
     108is not given, prints the location where executable files will be installed.
     109If
     110.B PATH
     111is given, specifies the location for installing executable files.
     112
     113.TP
     114.BI  \-s,\ \-script \ FILENAME           
     115Executes the given script with remaining arguments and exits.
     116
     117.TP
     118.B \-f,\ \-fetch
     119Only download, don't extract, build or install.
     120
     121.TP
     122.B \-v,\ \-verbose
     123Displays additional information (mainly for debugging).
     124
     125.TP
     126.B \-k,\ \-keep
     127Keeps intermediate files after building and installing.
     128
    52129.TP
    53 .BI \-csc\-option option
     130.BI \-c,\ \-csc\-option \ option
    54131Passes
    55132.B option
     
    62139
    63140.TP
    64 .BI \-destdir\ pathname
    65 Specifies alternative installation prefix by setting the
    66 .B installation-prefix
    67 parameter.
    68 
    69 .TP
    70 .B \-docindex
    71 Displays the path to the index-page of any installed extension-documentation. If the index page
    72 does not exist, it is created.
    73 
    74 .TP
    75 .B \-dont\-ask
    76 Do not ask the user before trying to download required extensions.
    77 
    78 .TP
    79 .BI \-eval\ expression
    80 Evaluates the given expression(s).
    81 
    82 .TP
    83 .B \-fetch
    84 Only download, don't extract, build or install.
    85 
    86 .TP
    87 .B \-fetch\-tree
    88 Downloads and prints the repository catalog to stdout.
    89 
    90 .TP
    91 .B \-help
    92 Show usage information and exit.
    93 
    94 .TP
    95 .BI \-host\ hostname:port
    96 Specifies alternative host for downloading extensions.
    97 .B port
    98 may be omitted and defaults to 80.
    99 
    100 .TP
    101 .B \-keep
    102 Keep temporary files and directories.
    103 
    104 .TP
    105 .B \-list
    106 List all installed extensions and exit, or show extension-information of extensions given on the
    107 command-line (following this option).
    108 
    109 .TP
    110 .BI \-local\ path
    111 Fetch extension sources from local filesystem at
    112 .B path
    113 instead of downloading egg from egg server.
    114 
    115 .TP
    116 .B \-no\-install
    117 Do not install generated binaries and/or support files. Any invocations of
     141.B \-d,\ \-dont\-ask
     142Does not ask the user before trying to download required extensions.
     143
     144.TP
     145.BI \-n,\ \-no\-install
     146Does not install generated binaries and support files after building.
     147Any invocations of
    118148.I install\-program
    119149,
    120150.I install\-extension
     151,
     152.I install\-script
    121153or
    122 .I install\-script
    123 will be be no-ops.
    124 
    125 .TP
    126 .B \-program\-path
    127 Display the path where executables are installed.
    128 
    129 .TP
    130 .BI \-program\-path\ directory
    131 Sets the location where executables are installed.
    132 
    133 .TP
    134 .BI \-proxy\ hostname:port
    135 Connect to server via proxy.
    136 .B port
    137 may be omitted and defaults to 80.
    138 
    139 .TP
    140 .B \-repository
    141 Displays the name of the extension repository.
    142 
    143 .TP
    144 .BI \-repository\ directory
    145 Sets the location of the extension repository for all subsequent operations.
    146 The default repository path is the installation library directory (usually
    147 .I \/usr\/local\/lib\/chicken
    148 , or (if set) the directory given in the environment variable
    149 .I CHICKEN\_REPOSITORY
    150 
    151 .TP
    152 .BI \-revision\ revision
    153 Specifies the subversion revision that you want to check out (only useful in
    154 combination with the
    155 .B \-svn
    156 option).
    157 
    158 .TP
    159 .BI \-run\ filename
    160 Load and execute given file.
    161 
    162 .TP
    163 .BI \-script\ filename
    164 Executes the given Scheme source file with all remaining arguments and exit.
    165 
    166 .TP
    167 .BI \-svn\ url
    168 Fetch extension sources from Subversion (http://subversion.tigris.org) repository,
    169 instead of downloading egg from egg server.
    170 
    171 .TP
    172 .B \-test
    173 If the extension sources contain a directory named
     154.I copy\-file
     155will be no-ops.
     156
     157.TP
     158.B \-i,\ \-docindex
     159Displays the path to the index-page of any installed
     160extension-documentation. If the index page does not exist, it is
     161created.
     162
     163.TP
     164.BI \-e,\ \-eval \ EXPRESSION
     165Evaluates the given expression(s).
     166
     167.TP
     168.BI \-t,\ \-test
     169If the
     170.B .egg
     171extension archive contains a directory named
    174172.B tests
    175173and this directory includes a file named
     
    180178
    181179.TP
    182 .BI \-tree\ filename
     180.B \-host\-extension
     181Compiles any extensions in "host" mode.
     182
     183.TP
     184.BI \-ls \ EXTENSION
     185Lists the installed files for the given extension.
     186
     187.TP
     188.B \-fetch\-tree
     189Downloads and prints the repository catalog to standard output.
     190
     191.TP
     192.BI \-create\-tree \ PATH
     193Creates repository catalog from SVN checkout.
     194
     195.TP
     196.BI \-tree \ FILENAME
    183197Uses the repository catalog stored in
    184 .B filename
     198.B FILENAME
    185199instead of downloading it.
    186200
    187 .TP
    188 .B \-uninstall
    189 Removes all following extensions from repository.
    190 
    191 .TP
    192 .B \-verbose
    193 Display additional information (mainly for debugging).
    194 
    195 .TP
    196 .B \-version
    197 Display version and exit.
     201
     202.TP
     203.BI \-svn \ URL
     204Fetches extension sources from an SVN repository instead of
     205downloading egg from egg server.
     206
     207.TP
     208.BI \-local \ PATH
     209Fetches extension sources from the local filesystem at
     210.B PATH
     211instead of downloading egg from egg server.
     212
     213.TP
     214.BI \-install-prefix \ PATH
     215Specifies alternative installation prefix. The installation paths for
     216all executable files, examples, and files installed with the
     217.I copy-file
     218and
     219.I move-file
     220procedures will be prepended by this prefix, if it is specified.
     221
     222.TP
     223.BI \-revision \ REVISION
     224Specifies the SVN revision that to check out (only useful in
     225combination with the
     226.B \-svn
     227option).
     228
     229.TP
     230.BI \-build\-prefix \ PATH
     231Specifies the location where
     232.I chicken-setup
     233will create build directories. The default location is the value
     234of environment variable
     235.I CHICKEN_TMPDIR
     236,
     237.I TMPDIR
     238or
     239.I /tmp/chicken-{MAJOR-VERSION}-build-{USER}
     240if none of those variables are found in the environment. If
     241.I /tmp
     242does not exist or is not writeable, then the build directory is
     243.I {HOME}/tmp/chicken-{MAJOR-VERSION}-build-{USER}
     244.
     245
     246
     247.TP
     248.BI \-download\-dir \ PATH
     249Specifies the location where chicken-setup will save downloaded files
     250The default is
     251.I {BUILD-PREFIX}/downloads)
     252
    198253
    199254.TP
    200255.B \-\-
    201 Ignore all further arguments.
     256Ignores all further arguments.
    202257
    203258.SH ENVIRONMENT\ VARIABLES
     
    205260.TP
    206261.B CHICKEN_PREFIX
    207 An alternative installation prefix, where the Scheme-to-C translator
    208 and any support files and libraries are located. Defaults to the installation
    209 time prefix given when configuring the system.
     262The installation prefix where CHICKEN Scheme and its support files and
     263libraries are located. Defaults to the installation time prefix given
     264when configuring the system.
     265
     266.TP
     267.B CHICKEN_INSTALL_PREFIX
     268An alternative installation prefix that will be prepended to extension
     269installation paths if specified.
    210270
    211271.TP
     
    222282.
    223283
     284.TP
     285.B CHICKEN_TMPDIR
     286The location where egg files will be unpacked and extensions compiled.
     287
    224288.SH DOCUMENTATION
    225289
     
    229293.SH BUGS
    230294Submit bug reports by e-mail to
    231 .I felix@call-with-current-continuation.org
     295.I chicken-janitors@nongnu.org
    232296, preferrably using the
    233297.B chicken\-bug
    234298tool.
    235299
    236 .SH AUTHOR
    237 .I chicken\-setup
    238 was written by Felix L. Winkelmann (felix@call-with-current-continuation.org).
     300.SH AUTHORS
     301Felix L. Winkelmann and the Chicken Team
    239302
    240303.SH SEE ALSO
  • chicken/branches/elf/branch-24012008/chicken-setup.scm

    r7764 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426
    3527
     
    3830  (uses srfi-1 regex utils posix tcp match srfi-18 srfi-13)
    3931  (export move-file run:execute make/proc uninstall-extension
    40           install-extension install-program install-script
    41           setup-verbose-flag setup-install-flag installation-prefix
    42           find-library find-header program-path remove-file* patch
    43           yes-or-no? setup-build-directory setup-root-directory
    44           create-directory test-compile try-compile copy-file run-verbose
    45           required-chicken-version required-extension-version
    46           cross-chicken ##sys#current-source-filename host-extension) )
     32          install-extension install-program install-script setup-verbose-flag
     33          setup-install-flag installation-prefix chicken-prefix find-library
     34          find-header program-path remove-file* patch yes-or-no?
     35          setup-build-directory setup-root-directory create-directory
     36          test-compile try-compile copy-file run-verbose
     37          required-chicken-version required-extension-version cross-chicken
     38          ##sys#current-source-filename host-extension) )
    4739
    4840
     
    119111
    120112(define-constant long-options
    121   '("-help" "-uninstall" "-list" "-run" "-repository" "-program-path" "-version" "-script"
    122     "-fetch" "-host" "-proxy" "-keep" "-verbose" "-csc-option" "-dont-ask" "-no-install" "-docindex" "-eval"
    123     "-debug" "-ls" "-release" "-test" "-fetch-tree" "-tree" "-svn" "-local" "-destdir" "-revision"
    124     "-host-extension") )
     113'("-help" "-uninstall" "-list" "-run" "-repository" "-program-path"
     114  "-version" "-script" "-fetch" "-host" "-proxy" "-keep" "-verbose"
     115  "-csc-option" "-dont-ask" "-no-install" "-docindex" "-eval"
     116  "-debug" "-ls" "-release" "-test" "-fetch-tree" "-tree" "-svn"
     117  "-local" "-revision" "-host-extension" "-build-prefix"
     118  "-download-path" "-install-prefix") )
     119
    125120
    126121(define-constant short-options
     
    136131    ("chicken-bug" . ,(foreign-value "C_CHICKEN_BUG_PROGRAM" c-string))))
    137132
    138 (define *install-bin-path*
    139   (or (and-let* ((p (getenv "CHICKEN_PREFIX")))
    140         (make-pathname p "bin") )
    141       (foreign-value "C_INSTALL_BIN_HOME" c-string) ) )
    142133
    143134(define *cc* (foreign-value "C_TARGET_CC" c-string))
     
    154145       (build-platform) ) )
    155146
    156 (define *windows-shell* (eq? *windows* 'mingw32))
     147(define *windows-shell* (or (eq? *windows* 'mingw32)
     148                            (eq? *windows* 'msvc)))
    157149(define *debug* #f)
    158150
    159151(register-feature! 'chicken-setup)
    160152
    161 (define program-path (make-parameter *install-bin-path*))
     153(define chicken-bin-path
     154  (or (and-let* ((p (getenv "CHICKEN_PREFIX")))
     155        (make-pathname p "bin") )
     156      (foreign-value "C_INSTALL_BIN_HOME" c-string) ) )
     157
     158(define chicken-prefix
     159  (or (getenv "CHICKEN_PREFIX")
     160      (match (string-match "(.*)/bin/?" chicken-bin-path)
     161             ((_ p) p)
     162             (_ "/usr/local") ) ) )
     163
     164(define example-path
     165  (make-parameter
     166   (or (and-let* ((p chicken-prefix))
     167         (make-pathname p "/share/chicken/examples") )
     168       "/usr/local/share/chicken/examples")))
     169
     170(define program-path (make-parameter chicken-bin-path))
     171
     172(define setup-build-prefix
     173  (make-parameter
     174   (or (getenv "CHICKEN_TMPDIR") (getenv "TMPDIR")
     175       (getenv "TMP") (getenv "TEMP")
     176       ((lambda (user)
     177          (and user  (file-write-access? "/tmp")
     178               (conc "/tmp/chicken-setup-" *major-version* "-" user)))
     179        (getenv "USER"))
     180       ((lambda (home user)
     181          (and home user  (conc home "/tmp/chicken-setup-" *major-version* "-" user)))
     182        (getenv "HOME") (getenv "USER"))
     183       (current-directory))))
     184
     185(define setup-download-directory  (make-parameter (make-pathname (setup-build-prefix) "downloads")))
     186(define setup-root-directory      (make-parameter #f))
     187(define setup-build-directory     (make-parameter #f))
     188(define setup-verbose-flag        (make-parameter #f))
     189(define setup-install-flag        (make-parameter #t))
     190
    162191(define (cross-chicken) (##sys#fudge 39))
    163192(define host-extension (make-parameter #f))
    164 
    165 (define setup-root-directory (make-parameter #f))
    166 (define setup-build-directory (make-parameter (current-directory)))
    167 (define setup-verbose-flag (make-parameter #f))
    168 (define setup-install-flag (make-parameter #t))
    169193
    170194(define *copy-command* (if *windows-shell* 'copy "cp -r"))
     
    174198(define *tar-program* 'tar)
    175199(define *fetch-only* #f)
    176 (define *temporary-directory* #f)
    177 (define *tmpdir-created* #f)
     200(define *builddir-created* #f)
    178201(define *keep-stuff* #f)
    179202(define *csc-options* '())
     
    185208(define *proxy-host* #f)
    186209(define *proxy-port* #f)
    187 (define *example-directory* (make-pathname (chicken-home) "examples"))
    188210(define *base-directory* (current-directory))
    189211(define *fetch-tree-only* #f)
    190212(define *svn-repository* #f)
    191213(define *local-repository* #f)
    192 (define *destdir* #f)
    193 (define *repository-hosts*
    194   (list (list "www.call-with-current-continuation.org" *default-eggdir* 80)))
     214(define *repository-hosts* (list (list "www.call-with-current-continuation.org" *default-eggdir* 80)))
    195215(define *revision* #f)
    196216(define *run-tests* #f)
     
    198218
    199219
     220; Convert a string with a version (such as "1.22.0") to a list of the
     221; numbers (such as (1 22 0)). If one of the version components cannot
     222; be converted to a number, then it is kept as a string.
     223
     224(define (version-string->numbers string)
     225  (map (lambda (x) (or (string->number x) (->string x)))
     226       (string-split string ".")))
     227
     228(define (numbers->version-string numbers)
     229  (string-intersperse (map ->string numbers) "."))
     230
     231; Given two lists with numbers corresponding to a software version (as returned
     232; by version-string->numbers), check if the first is greater than the second.
     233
     234(define (version-numbers> a b)
     235  (match (list a b)
     236         ((() _)   #f)
     237         ((_  ())  #t)
     238         (((a1 . an) (b1 . bn))
     239          (cond ((and (number? a1) (number? b1))
     240                 (cond ((> a1 b1) #t) ((= a1 b1) (version-numbers> an bn)) (else #f)))
     241                ((and (string? a1) (string? b1)) 
     242                 (cond ((string> a1 b1) #t) ((string= a1 b1) (version-numbers> an bn)) (else #f)))
     243                (else (version-numbers> (cons (->string a1) an) (cons (->string b1) bn)))))
     244         (else (error 'version-numbers> "invalid revisions: " a b))))
     245
    200246;;; File-system routines
    201 
    202 (define create-directory/parents
    203   (let ([create-directory create-directory])
    204     (lambda (dir)
    205       (let loop ([dir dir])
    206         (when (and dir (not (directory? dir)))
    207           (loop (pathname-directory dir))
    208           (create-directory dir))) ) ) )
    209247
    210248(define create-directory
     
    215253        (lambda (dir)
    216254          (verb dir)
    217           (create-directory/parents dir) )
     255          (system* "mkdir ~a" (quotewrap dir)))
    218256        (lambda (dir)
    219257          (verb dir)
     
    221259
    222260
     261
    223262;;; Helper stuff
    224263
     264(define (quotewrapped? str)
     265  (and (string? str) (string-prefix? "\"" str) (string-suffix? "\"" str) ))
     266
    225267(define (quotewrap str)
    226   (if (or (string-any char-whitespace? str)
    227           (and *windows-shell* (string-any (lambda (c) (char=? c #\/)) str)))
    228       (string-append "\"" str "\"")
    229       str) )
     268  (cond ((quotewrapped? str) str)
     269        ((or (string-any char-whitespace? str)
     270             (and *windows-shell* (string-any (lambda (c) (char=? c #\/)) str)))
     271         (string-append "\"" str "\""))
     272        (else str)))
    230273
    231274(define (abort-setup)
     
    273316          (cons* (quotewrap
    274317                  (make-pathname
    275                    *install-bin-path*
     318                   chicken-bin-path
    276319                   (cdr (assoc prg *installed-executables*))))
    277320                 "-feature" "compiling-extension"
     
    279322          " ") )
    280323        ((assoc prg *installed-executables*) =>
    281          (lambda (a) (quotewrap (make-pathname *install-bin-path* (cdr a)))))
     324         (lambda (a) (quotewrap (make-pathname chicken-bin-path (cdr a)))))
    282325        (else prg) ) )
    283326
     
    456499         (filter-map
    457500          (lambda (d)
    458             (and-let* ((mf (or (file-exists? (make-pathname d d "meta"))
    459                                (file-exists? (make-pathname (list d "trunk") d "meta")))))
     501            (and-let* ((mf (or (file-exists? (make-pathname (list eggdir d) d "meta"))
     502                               (file-exists? (make-pathname (list eggdir d "trunk") d "meta")))))
    460503              (display mf (current-error-port))
    461504              (newline (current-error-port))
     
    470513               ,(conc e ".egg")
    471514               ,@(if needs (cdr needs) '())))))
    472      *eggs*)
     515     eggs)
    473516    (write-char #\))))
    474517
     
    480523usage: chicken-setup [OPTION ...] FILENAME
    481524
    482   -h  -help                      show this text and exit
    483   -V  -version                   show version of this program and exit
    484       -release                   show release number and exit
    485   -R  -repository [PATH]         prints the location of the extension repository
    486   -u  -uninstall                 remove the following extension from repository
    487   -H  -host HOSTNAME[:PORT]      specify alternative host for downloading
    488   -p  -proxy HOSTNAME[:PORT]     connect via proxy
    489   -l  -list [NAME ...]           list installed extensions or show extension information
    490   -r  -run FILENAME              load and execute given file
    491   -P  -program-path DIRECTORY    specify path for installing executables or scripts
    492   -s  -script FILENAME           execute script with remaining arguments and exit
     525  -h  -help                      shows this text and exits
     526  -V  -version                   shows version of this program and exits
     527      -release                   shows release number and exits
     528  -R  -repository [PATH]         if PATH is not given, prints the location of the extension repository
     529                                 if PATH is given, specifies the location for the extension repository
     530  -u  -uninstall                 removes the following extension from repository
     531  -H  -host HOSTNAME[:PORT]      specifies alternative host for downloading
     532  -p  -proxy HOSTNAME[:PORT]     connects via proxy
     533  -l  -list [NAME ...]           lists installed extensions or shows extension information
     534  -r  -run FILENAME              loads and executes given file
     535  -P  -program-path [PATH]       if PATH is not given, prints the location where executables will be installed
     536                                 if PATH is given, specifies the location for installing executables
     537  -s  -script FILENAME           executes script with remaining arguments and exits
    493538  -f  -fetch                     only download, don't extract, build or install
    494   -v  -verbose                   be verbose
    495   -k  -keep                      don't delete intermediate files
    496   -c  -csc-option OPTION         pass extra option to csc (if run with `(run (csc ...))')
     539  -v  -verbose                   verbose mode
     540  -k  -keep                      keeps intermediate files after building and installing
     541  -c  -csc-option OPTION         passes extra option to csc (if run with `(run (csc ...))')
    497542  -d  -dont-ask                  always download, if asked
    498   -n  -no-install                don't install generated binaries and support files
    499   -i  -docindex                  display path for documentation index
    500   -e  -eval EXPRESSION           evaluate expression
    501   -t  -test                      run test suite, if it exists
    502       -host-extension            compile any extensions in "host" mode
    503       -ls EXTENSION              list installed files for extension
    504       -fetch-tree                download and show repository catalog
    505       -create-tree               create repository catalog from SVN checkout
    506       -tree FILENAME             use repository catalog from given file
    507       -svn URL                   fetch extension from subversion repository
    508       -local PATH                fetch extension from local filesystem
    509       -destdir PATH              specify alternative installation prefix
    510       -revision REV              specify SVN revision for checkout
    511   --                             ignore all following arguments
     543  -n  -no-install                does not install generated binaries and support files
     544  -i  -docindex                  displays path for documentation index
     545  -e  -eval EXPRESSION           evaluates expression
     546  -t  -test                      runs test suite, if it exists
     547      -host-extension            compiles any extensions in "host" mode
     548      -ls EXTENSION              lists installed files for extension
     549      -fetch-tree                downloads and show repository catalog
     550      -create-tree DIRECTORY     creates repository catalog from SVN checkout
     551      -tree FILENAME             uses repository catalog from given file
     552      -svn URL                   fetches extension from subversion repository
     553      -local PATH                fetches extension from local filesystem
     554      -revision REV              specifies SVN revision for checkout
     555      -build-prefix PATH         location where chicken-setup will create egg build directories
     556                                 (default: the value of environment variable CHICKEN_TMPDIR, TMPDIR or
     557                                  /tmp/chicken-setup-{MAJOR-VERSION}-{USER}
     558                                  if none of these variables are found in the environment)
     559      -download-path PATH         location where chicken-setup will save downloaded files
     560                                 (default: {BUILD-PREFIX}/downloads)
     561      -install-prefix PATH       specifies alternative installation prefix
     562  --                             ignores all following arguments
    512563
    513564  Builds and installs extension libraries.
     
    524575
    525576(define installation-prefix
    526   (make-parameter
    527    (or (getenv "CHICKEN_PREFIX")
    528        (match (string-match "(.*)/bin/?" *install-bin-path*)
    529          ((_ p) p)
    530          (_ #f) ) ) ) )
     577  (make-parameter (or (getenv "CHICKEN_INSTALL_PREFIX") #f)))
    531578
    532579(define (with-ext filename ext)
     
    567614            (write-setup-info (with-output-to-file setup-file
    568615                                (cut pp info))))
    569         (unless *windows-shell* (run (chmod a+r ,setup-file)))
     616        (unless *windows-shell* (run (chmod a+r ,(quotewrap setup-file))))
    570617        write-setup-info))))
    571618
     
    591638          (values '() oinfo) ) ) ) )
    592639
    593 (define (compute-tmpdir fname)
    594   (if (equal? "egg-dir" (pathname-extension fname))
    595       fname
    596       (string-append fname "-dir") ) )
     640(define (compute-builddir fpath)
     641  (if (equal? "egg-dir" (pathname-extension fpath)) fpath
     642      (let ((fname (pathname-strip-directory fpath)))
     643        (let loop ((num (random 10000)))
     644          (let* ((buildname (string-append "build." (number->string num)))
     645                 (path  (make-pathname (setup-build-prefix) buildname (string-append fname "-dir") )))
     646            (if (file-exists? path) (loop (random 10000))
     647                path))))))
     648
    597649
    598650(define (chdir dir)
     
    600652  (change-directory dir) )
    601653
    602 (define (rmtmpdir)
     654(define (clear-builddir)
    603655  (unless (string=? (current-directory) *base-directory*)
    604656    (chdir *base-directory*) )
    605   (when *tmpdir-created*
    606     (set! *tmpdir-created* #f)
     657  (when *builddir-created*
     658    (set! *builddir-created* #f)
    607659    (unless *keep-stuff*
    608       (when (setup-verbose-flag) (printf "removing temporary directory `~A'~%" *temporary-directory*))
     660      (when (setup-verbose-flag) (printf "removing egg build directory `~A'~%" (setup-build-directory)))
    609661      (handle-exceptions ex
    610           (warning "removal of temporary directory failed" *temporary-directory*)
    611         (run (,*remove-command* ,(quotewrap *temporary-directory*))) )) ) )
     662          (warning "removal of egg build directory failed" (setup-build-directory))
     663        (run (,*remove-command* ,(quotewrap (setup-build-directory))) )) ) ))
    612664
    613665(define (unpack/enter filename)
     
    615667    (with-input-from-file fn
    616668      (lambda () (string=? "\x1f\x8b" (read-string 2))) ) )
    617   (let ((tmpdir (compute-tmpdir filename)))
     669  (let ((tmpdir (compute-builddir filename)))
    618670    (cond ((file-exists? tmpdir)
    619671           (chdir tmpdir)
     
    621673          (else
    622674           (create-directory tmpdir)
    623            (set! *tmpdir-created* #t)
     675           (set! *builddir-created* #t)
    624676           (chdir tmpdir)
    625677           (setup-build-directory (current-directory))
    626            (let ((fn2 (string-append "../" filename))
     678           (let ((fn2 (if (and (not (or *local-repository* (with-ext filename "egg") (with-ext filename "egg-dir")))
     679                               (not (string-prefix? (setup-download-directory) filename)))
     680                          (make-pathname (setup-download-directory) filename)
     681                          filename))
    627682                 (v (setup-verbose-flag)) )
    628683             (if (testgz fn2)
    629                  (run (,*gzip-program* -d -c ,fn2 |\|| ,*tar-program* ,(if v 'xvf 'xf) -))
    630                  (run (,*tar-program* ,(if v 'xvf 'xf) ,fn2)) ) ) ) )
    631     (set! *temporary-directory* tmpdir) ) )
    632 
    633 (define (copy-file from to #!optional (err #t))
     684                 (run (,*gzip-program* -d -c ,(quotewrap fn2) |\|| ,*tar-program* ,(if v 'xvf 'xf) -))
     685                 (run (,*tar-program* ,(if v 'xvf 'xf) ,(quotewrap fn2))) ) ) ) )
     686    ))
     687
     688(define (copy-file from to #!optional (err #t) (prefix (installation-prefix)))
    634689  (let ((from (if (pair? from) (car from) from))
    635         (to (if (pair? from) (make-pathname to (cadr from)) to)) )
     690        (to ((lambda (pre) (let ((to-path (if (pair? from) (make-pathname to (cadr from)) to)))
     691                             (if (and pre (not (string-prefix? pre to-path)))
     692                                 (make-pathname pre to-path) to-path)))
     693             prefix)))
    636694    (ensure-directory to)
    637695    (cond ((or (glob? from) (file-exists? from))
    638            (run (,*copy-command* ,(quotewrap from) ,(quotewrap to))) )
     696           (begin
     697             (run (,*copy-command* ,(quotewrap from) ,(quotewrap to)))
     698             to))
    639699          (err (error "file does not exist" from))
    640700          (else (warning "file does not exist" from)))))
    641701
    642702(define (move-file from to)
    643   (let ((from (if (pair? from) (car from) from))
    644         (to (if (pair? from) (make-pathname to (cadr from)) to)) )
     703  (let ((from  (if (pair? from) (car from) from))
     704        (to    (let ((to-path (if (pair? from) (make-pathname to (cadr from)) to)))
     705                 (if (and pre (not (string-prefix? pre to-path)))
     706                     (make-pathname pre to-path) to-path))))
    645707    (ensure-directory to)
    646708    (run (,*move-command* ,(quotewrap from) ,(quotewrap to)) ) ) )
     
    686748                           (when (and (not *windows*)
    687749                                      (equal? "so" (pathname-extension to)))
    688                              (run (,*remove-command* ,to)) )
     750                             (run (,*remove-command* ,(quotewrap to)) ))
    689751                           (copy-file from to)
    690752                           (unless *windows-shell*
    691                              (run (chmod a+r ,to)))
     753                             (run (chmod a+r ,(quotewrap to))))
    692754                           (and-let* ((static (assq 'static info)))
    693755                             (when (and (eq? (software-version) 'macosx)
    694756                                        (equal? (cadr static) from)
    695757                                        (equal? (pathname-extension to) "a"))
    696                                (run (ranlib ,to)) ) )
     758                               (run (ranlib ,(quotewrap to)) ) ))
    697759                           (make-dest-pathname rpath f)))
    698760                       files) ) )
     
    707769          (set! *rebuild-doc-index* #t)) )
    708770      (and-let* ((exs (assq 'examples info)))
    709         (print "\n* Installing example files in " *example-directory* ":")
    710         (for-each
    711          (lambda (f)
    712            (copy-file f (make-pathname *example-directory* f) #f)
    713            (unless *windows-shell*
    714              (run (chmod a+rx ,*example-directory*))) )
    715          (cdr exs))
    716         (newline) )
     771        (let ((example-dest
     772               ((lambda (pre) (if pre (make-pathname pre (example-path)) (example-path)))
     773                (installation-prefix))))
     774          (print "\n* Installing example files in " example-dest ":")
     775          (for-each
     776           (lambda (f)
     777             (let ((destf (make-pathname example-dest f)))
     778               (copy-file f destf #f)
     779               (unless *windows-shell*
     780                 (run (chmod a+rx ,(quotewrap destf))) ) ))
     781           (cdr exs))
     782          (newline) ))
    717783      (write-info id dests info) ) ) )
    718784
     
    724790  (when (setup-install-flag)
    725791    (let* ((files (check-filelist (if (list? files) files (list files))))
    726            (ppath (if *destdir* (make-pathname *destdir* "bin") (program-path)))
     792           (ppath ((lambda (pre) (if pre (make-pathname pre (program-path)) (program-path)))
     793                   (installation-prefix)))
    727794           (files (if *windows*
    728795                      (map (lambda (f)
     
    737804                           (copy-file from to)
    738805                           (unless *windows-shell*
    739                                    (run (chmod a+r ,to)))
     806                                   (run (chmod a+r ,(quotewrap to))))
    740807                           to) )
    741808                       files) ) )
     
    745812  (when (setup-install-flag)
    746813    (let* ((files (check-filelist (if (list? files) files (list files))))
    747            (ppath (if *destdir* (make-pathname *destdir* "bin") (program-path)))
     814           (ppath ((lambda (pre) (if pre (make-pathname pre (program-path)) (program-path)))
     815                   (installation-prefix)))
    748816           (pfiles (map (lambda (f)
    749817                          (let ((from (if (pair? f) (car f) f))
     
    751819                            (copy-file from to)
    752820                            (unless *windows-shell*
    753                                     (run (chmod a+r ,to)))
     821                                    (run (chmod a+r ,(quotewrap to))))
    754822                            to) )
    755823                        files) ) )
     
    778846
    779847(define (repo-path #!optional ddir?)
    780   (let ((p (if (and ddir? *destdir*)
    781                (make-pathname
    782                 (list *destdir* "lib/chicken")
    783                 (pathname-file (repository-path))) ; we need the binary-compat. version
     848  (let ((p (if (and ddir? (installation-prefix))
     849               (make-pathname (installation-prefix) (repository-path))
    784850               (repository-path))) )
    785851    (ensure-directory p)
     
    794860          (create-directory dir)
    795861          (unless *windows-shell*
    796                   (run (chmod a+x ,dir)))))))
     862                  (run (chmod a+x ,(quotewrap dir))))))))
    797863
    798864(define (try-compile code #!key c++ (cc (if c++ *cxx* *cc*)) (cflags "") (ldflags "")
     
    835901      ((ext version . more)
    836902       (let ((info (extension-information ext))
    837              (version (->string version)) )
     903             (required-version (->string version)) )
    838904         (if info
    839905             (let ((ver (and (assq 'version info) (cadr (assq 'version info)))))
    840906               (cond ((not ver) (upgrade-message ext "has no associated version information"))
    841                      ((string-ci<? (->string ver) version)
     907                     ((version-numbers>
     908                       (version-string->numbers required-version)
     909                       (version-string->numbers (->string ver)))
    842910                      (upgrade-message
    843911                       ext
    844912                       (sprintf "is older than ~a, which is what this extension requires"
    845                                 version) ) )
     913                                required-version) ) )
    846914                     (else (loop more)) ) )
    847915             (upgrade-message ext "is not installed") ) ) )
     
    9421010  (cond (*local-repository*
    9431011         (when (setup-verbose-flag) (printf "fetching from local directory ~a ...~%" *local-repository*))
    944          (let ((p (->string item)))
    945            (copy-file (make-pathname *local-repository* p) (make-pathname #f p "egg-dir")) ) )
     1012         (let* ((p  (->string item))
     1013               (fpath  (make-pathname (setup-download-directory) p "egg-dir")))
     1014           (copy-file (make-pathname *local-repository* p) fpath #t #f)))
     1015
    9461016        (*svn-repository*
    9471017         (when (setup-verbose-flag) (printf "fetching from svn repository ~a ...~%" *svn-repository*))
    948          (let ((p (->string item)))
     1018         (let* ((p (->string item))
     1019               (fpath (make-pathname (setup-download-directory) p "egg-dir")))
    9491020           (run (svn co ,(if *revision* (conc "--revision " *revision*) "")
    950                      ,(make-pathname *svn-repository* p) ,(make-pathname #f p "egg-dir"))) ) )
     1021                     ,(make-pathname *svn-repository* p) ,(quotewrap fpath)))
     1022           fpath))
     1023
    9511024        (else
    9521025         (match hostdata
     
    9681041                          (close-input-port i)
    9691042                          (close-output-port o)
    970                           (with-output-to-file (pathname-strip-directory fname)
    971                             (cut display data)
    972                             binary:) )
     1043                          (if (not (file-exists? (setup-download-directory)))
     1044                              (create-directory (setup-download-directory)))
     1045                          (let ((fpath (make-pathname (setup-download-directory) (pathname-strip-directory fname))))
     1046                            (with-output-to-file fpath
     1047                              (cut display data)
     1048                              binary:)
     1049                            fpath))
    9731050                        (loop) ) ) ) ) ) )
    9741051           (x (error "(internal) invalid host" x)) ) ) ) )
     
    9981075               *last-decent-host*
    9991076               (pathname-file ext)
    1000                (pathname-replace-extension ext "egg") )
    1001               #t)
     1077               (pathname-replace-extension ext "egg") ))
     1078
    10021079             (else
    10031080              (download-repository-tree)
     
    10111088                             (print "installing required extensions ...")
    10121089                             (for-each (cut install <>) (map ->string reqs)) )
    1013                            (begin (download-data *last-decent-host* (first a)) #t) ) )
     1090                           (download-data *last-decent-host* (first a))) )
    10141091                      (else
    10151092                       (error "Extension does not exist in the repository" ext)) ) ) ) ) ) )
     
    10231100      (cond ((and df (with-ext filename "setup")) => run-setup-script)
    10241101            ((or (with-ext filename "egg") (with-ext filename "egg-dir")) =>
    1025              (lambda (f)
     1102             (lambda (fpath)
     1103               (let ((f (pathname-strip-directory fpath)))
     1104                 (when df
     1105                   (unpack/enter fpath)
     1106                   (let ((sfile (pathname-replace-extension f "setup")))
     1107                     (when (and (not (file-exists? sfile)) (file-exists? "tags") )
     1108                       (let ((ds (sort (map version-string->numbers (directory "tags")) version-numbers>)))
     1109                         (when (pair? ds)
     1110                           (let ((d (make-pathname "tags" (car ds))))
     1111                             (chdir d) ) )  ) )
     1112                     (loop sfile)
     1113                     (clear-builddir) ) ) ) ))
     1114            ((fetch-file filename) =>
     1115             (lambda (fpath)
     1116               (set! *fetched-eggs*
     1117                     (append
     1118                      *fetched-eggs*
     1119                      (if fpath (list fpath) (list (make-pathname (current-directory) filename "egg")))))
    10261120               (when df
    1027                  (unpack/enter f)
    1028                  (let ((sfile (pathname-replace-extension f "setup")))
    1029                    (when (and (not (file-exists? sfile)) (file-exists? "tags") )
    1030                      (let ((ds (sort (directory "tags") string>=?)))
    1031                        (when (pair? ds)
    1032                          (let ((d (make-pathname "tags" (car ds))))
    1033                            (chdir d)
    1034                            (setup-build-directory d) ) ) ) )
    1035                    (loop sfile)
    1036                    (rmtmpdir) ) ) ) )
    1037             ((fetch-file filename)
    1038              (set! *fetched-eggs*
    1039                (append
    1040                 *fetched-eggs*
    1041                 (list (make-pathname (current-directory) filename "egg"))))
    1042              (when df
    1043                (loop (pathname-file filename))))))))
     1121                 (loop fpath))))))))
    10441122
    10451123
     
    10651143  (let ((rpath (repository-path))
    10661144        (hn (get-host-name)))
    1067     (with-output-to-file (doc-stylesheet)
     1145    (with-output-to-file (doc-stylesheet #t)
    10681146      (lambda () (display #<<EOF
    10691147body, html {
     
    11421220}
    11431221EOF
    1144                           )))
    1145     (with-output-to-file (doc-index)
     1222    )))
     1223    (with-output-to-file (doc-index #t)
    11461224      (lambda ()
    11471225        (print "<html><head><title>Egg documentation index for " hn
     
    11761254                  string<?) ) )
    11771255          (display "</tbody></table></body></font></html>\n") ) ) ) ) )
    1178 
    11791256
    11801257;;; Output stuff
     
    12871364         (print (program-path))
    12881365         (exit) )
    1289         (("-destdir" path . more)
    1290          (set! *example-directory* (make-pathname path "examples"))
    1291          (set! *destdir* path)
     1366        (("-install-prefix" path . more)
    12921367         (installation-prefix path)
     1368         (loop more) )
     1369        (("-build-prefix" path . more)
     1370         (setup-build-prefix path)
     1371         (loop more) )
     1372        (("-download-path" path . more)
     1373         (setup-download-directory path)
    12931374         (loop more) )
    12941375        (("-program-path" dir . more)
     
    13471428         (loop more) )
    13481429        (("-docindex" . more)
    1349          (let ((di (doc-index)))
     1430         (let ((di (doc-index #t)))
    13501431           (unless (file-exists? di)
    13511432             (build-doc-index) )
     
    13791460         (host-extension #t)
    13801461         (loop more) )
    1381         (((or "-run" "-script" "-proxy" "-host" "-csc-option" "-ls" "-destdir" "-tree" "-local" "-svn" "-eval"))
     1462        (((or "-run" "-script" "-proxy" "-host" "-csc-option" "-ls" "-install-prefix"
     1463              "-tree" "-local" "-svn" "-eval" "-create-tree" "-build-prefix" "-download-dir"))
    13821464         (error "missing option argument" (car args)) )
    13831465        ((filename . more)
     
    14281510     (main (append (string-split (or (getenv "CHICKEN_SETUP_OPTIONS") ""))
    14291511                   (command-line-arguments) ) ) ) )
    1430   (rmtmpdir) )
     1512  (clear-builddir) )
  • chicken/branches/elf/branch-24012008/chicken.1

    r7180 r10415  
    428428.I Chicken\ User's\ Manual
    429429
    430 .SH BUGS
    431 
    432 Submit bug reports by e-mail to
    433 .I felix@call-with-current-continuation.org
    434 , preferrably using the
    435 .B chicken\-bug
    436 tool.
    437 
    438 .SH AUTHOR
    439 
    440 .I Chicken
    441 was implemented by Felix L. Winkelmann (felix@call-with-current-continuation.org).
     430.SH AUTHORS
     431
     432Felix L. Winkelmann and The Chicken Team.
    442433
    443434.SH SEE ALSO
  • chicken/branches/elf/branch-24012008/chicken.h

    r7777 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426*/
    35 
    3627
    3728/* Configuration: */
     
    9384#  undef  C_externimport
    9485#  undef  C_externexport
    95 #  define C_externimport           C_extern __declspec(dllimport)
    9686#  define C_externexport           C_extern __declspec(dllexport)
    9787#  undef  C_varextern
     
    10090#   define C_varextern             C_extern __declspec(dllexport)
    10191#   define C_fctexport             __declspec(dllexport)
     92#   define C_externimport          C_extern __declspec(dllexport)
    10293#  else
    10394#   define C_varextern             C_extern __declspec(dllimport)
    10495#   define C_fctexport             __declspec(dllimport)
     96#   define C_externimport          C_extern __declspec(dllimport)
    10597#  endif
    10698# elif defined(__WATCOMC__)
     
    174166#if defined(__APPLE__) && defined(__MACH__)
    175167# define C_MACOSX
    176 #elif defined(__MWERKS__) && !defined(__INTEL__)
    177 /* This is a rather crude way of assuming this is MacOS 9 or lower! */
    178 # define C_MACOS
    179168#endif
    180169
     
    208197#if defined(__MINGW32__)
    209198# include <sys/param.h>
     199#elif defined(__CYGWIN__)
     200# include <endian.h>
    210201#elif defined(__linux__)
    211202# include <endian.h>
     
    242233#endif
    243234
    244 #ifdef C_MACOS
    245 # include <alloca.h>
    246 int strncasecmp(const char *one, const char *two, size_t n);
    247 #endif
    248 
    249235#ifdef __MINGW32__
    250236# include <malloc.h>
     
    262248typedef unsigned  __int16  uint16_t;
    263249typedef __int32            int32_t;
    264 typedef unsigned __int32   int32_t;
    265 typedef __int64            uint64_t;
     250typedef unsigned __int32   uint32_t;
     251typedef __int64            int64_t;
    266252typedef unsigned __int64   uint64_t;
    267253# pragma warning(disable: 4101)
     
    489475#define C_RUNTIME_SAFE_DLOAD_UNSAFE_ERROR             34
    490476#define C_BAD_ARGUMENT_TYPE_NO_FLONUM_ERROR           35
     477#define C_BAD_ARGUMENT_TYPE_NO_CLOSURE_ERROR          36
    491478
    492479
     
    10571044#endif
    10581045
     1046#define C_i_check_closure(x)            C_i_check_closure_2(x, C_SCHEME_FALSE)
    10591047#define C_i_check_exact(x)              C_i_check_exact_2(x, C_SCHEME_FALSE)
     1048#define C_i_check_inexact(x)            C_i_check_inexact_2(x, C_SCHEME_FALSE)
    10601049#define C_i_check_number(x)             C_i_check_number_2(x, C_SCHEME_FALSE)
    10611050#define C_i_check_string(x)             C_i_check_string_2(x, C_SCHEME_FALSE)
     
    12901279C_fctexport C_word C_exit_runtime(C_word code);
    12911280C_fctexport C_word C_fcall C_display_flonum(C_word port, C_word n) C_regparm;
     1281C_fctexport C_word C_fcall C_set_print_precision(C_word n) C_regparm;
     1282C_fctexport C_word C_fcall C_get_print_precision(void) C_regparm;
    12921283C_fctexport C_word C_fcall C_read_char(C_word port) C_regparm;
    12931284C_fctexport C_word C_fcall C_peek_char(C_word port) C_regparm;
     
    14551446C_fctexport C_word C_fcall C_i_length(C_word lst) C_regparm;
    14561447C_fctexport C_word C_fcall C_i_inexact_to_exact(C_word n) C_regparm;
     1448C_fctexport C_word C_fcall C_i_check_closure_2(C_word x, C_word loc) C_regparm;
    14571449C_fctexport C_word C_fcall C_i_check_exact_2(C_word x, C_word loc) C_regparm;
     1450C_fctexport C_word C_fcall C_i_check_inexact_2(C_word x, C_word loc) C_regparm;
    14581451C_fctexport C_word C_fcall C_i_check_number_2(C_word x, C_word loc) C_regparm;
    14591452C_fctexport C_word C_fcall C_i_check_string_2(C_word x, C_word loc) C_regparm;
     
    15061499C_fctexport C_word C_fcall C_i_o_fixnum_plus(C_word x, C_word y) C_regparm;
    15071500C_fctexport C_word C_fcall C_i_o_fixnum_difference(C_word x, C_word y) C_regparm;
     1501C_fctexport C_word C_fcall C_i_o_fixnum_and(C_word x, C_word y) C_regparm;
     1502C_fctexport C_word C_fcall C_i_o_fixnum_ior(C_word x, C_word y) C_regparm;
     1503C_fctexport C_word C_fcall C_i_o_fixnum_xor(C_word x, C_word y) C_regparm;
    15081504
    15091505C_fctexport C_word C_fcall C_i_foreign_char_argumentp(C_word x) C_regparm;
  • chicken/branches/elf/branch-24012008/chicken.scm

    r6827 r10415  
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     4; Copyright (c) 2008, The Chicken Team
    45; All rights reserved.
    56;
     
    2324; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    2425; POSSIBILITY OF SUCH DAMAGE.
    25 ;
    26 ; Send bugs, suggestions and ideas to:
    27 ;
    28 ; felix@call-with-current-continuation.org
    29 ;
    30 ; Felix L. Winkelmann
    31 ; Unter den Gleichen 1
    32 ; 37130 Gleichen
    33 ; Germany
    3426
    3527
     
    7971  (include "chicken-more-macros")
    8072  (include "chicken-ffi-macros") )
    81 
    82 ;;(##sys#provide 'extras 'srfi-1 'srfi-4)
    8373
    8474
  • chicken/branches/elf/branch-24012008/chicken.texi

    r5923 r10415  
    11\input texinfo @c -*- texinfo -*-
    2 @setfilename chicken.info
    32@settitle Chicken Scheme Reference Manual
    43@setchapternewpage on
    5 @ifinfo
    6 @format
    7 INFO-DIR-SECTION Programming
    8 START-INFO-DIR-ENTRY
    9 * Chicken: (chicken.info). A compiler that translates Scheme source files into C.
    10 END-INFO-DIR-ENTRY
    11 @end format
    12 @end ifinfo
    134@copying
    14 Copyright 2007 Felix Winkelmann
     5Copyright 2007-2008 Felix Winkelmann and the Chicken Team
    156@end copying
    167@titlepage
    178@sp 10
    189@title{Chicken Scheme Reference Manual}
    19 @author{Felix Winkelmann}
     10@author{Felix Winkelmann and the Chicken Team}
    2011@comment  The following two commands start the copyright page.
    2112@page
    2213@vskip 0pt plus 1fill
    23 Copyright 2007 Felix Winkelmann
     14Copyright 2007-2008 Felix Winkelmann and the Chicken Team
    2415@end titlepage
    2516@node Top, The User's Manual, (dir), (dir)
     
    2819@menu
    2920* The User's Manual::
     21* Getting started::
    3022* Basic mode of operation::
    3123* Using the compiler::
     
    4941* Unit regex::
    5042* Unit srfi-18::
     43* Unit srfi-69::
    5144* Unit posix::
    5245* Unit utils::
     
    6861* Bibliography::
    6962@end menu
    70 @node The User's Manual, Basic mode of operation, Top, Top
     63@node The User's Manual, Getting started, Top, Top
    7164@chapter The User's Manual
    7265
    7366
    74 @emph{(This document describes version 2.635)}
    75 
    76 @b{CHICKEN is a compiler that translates Scheme source files into C}, which in turn can be fed to a C-compiler to generate a standalone executable.  An interpreter is also available and can be used as a scripting environment or for testing programs before compilation.
    77 
    78 This package is distributed under the @b{BSD license} and as such is free to use and modify.
    79 
    80 The method of compilation and the design of the runtime-system follow closely Henry Baker's @uref{http://home.pipeline.com/~hbaker1/CheneyMTA.html, CONS Should Not CONS Its Arguments, Part II: Cheney on the M.T.A.} paper and expose a number of interesting properties:
     67This is the user's manual for the CHICKEN Scheme compiler, version 3.1.2
     68
     69@table @b
     70@item @ref{Getting started, Getting started}
     71
     72What is CHICKEN and how do I use it?
     73@item @ref{Basic mode of operation, Basic mode of operation}
     74
     75Compiling Scheme files.
     76@item @ref{Using the compiler, Using the compiler}
     77
     78Explains how to use CHICKEN to compile programs and execute them.
     79@item @ref{Using the interpreter, Using the interpreter}
     80
     81Invocation and usage of @code{csi}, the CHICKEN interpreter
     82@item @ref{Supported language, Supported language}
     83
     84The language implemented by CHICKEN (deviations from the standard and extensions).
     85@item @ref{Interface to external functions and variables, Interface to external functions and variables}
     86
     87Accessing C and C++ code and data.
     88@item @ref{chicken-setup, chicken-setup}
     89
     90Packaging and installing extension libraries.
     91@item @ref{Data representation, Data representation}
     92
     93How Scheme data is internally represented.
     94@item @ref{Bugs and limitations, Bugs and limitations}
     95
     96Yes, there are some.
     97@item @ref{FAQ, FAQ}
     98
     99A list of Frequently Asked Questions about CHICKEN (and their answers!).
     100@item @ref{Acknowledgements, Acknowledgements}
     101
     102A list of some of the people that have contributed to make CHICKEN what it is.
     103@item @ref{Bibliography, Bibliography}
     104
     105Links to documents that may be of interest.
     106
     107@end table
     108@node Getting started, Basic mode of operation, The User's Manual, Top
     109@chapter Getting started
     110
     111@menu
     112* Getting started - Scheme::
     113* Getting started - Chicken::
     114* Getting started - Chicken repositories; websites; and community::
     115* Getting started - Installing Chicken::
     116* Getting started - Development environments::
     117* Getting started - The Read-Eval-Print loop::
     118* Getting started - The compiler::
     119* Getting started - Installing an egg::
     120* Getting started - Accessing C libraries::
     121
     122@end menu
     123
     124
     125Chicken is a compiler that translates Scheme source files into C, which in turn can be fed to a C compiler to generate a standalone executable.  An interpreter is also available and can be used as a scripting environment or for testing programs before compilation.
     126
     127This chapter is designed to get you started with Chicken programming, describing what it is and what it will do for you, and covering basic use of the system. With almost everything discussed here, there is more to the story, which the remainder of the manual reveals. Here, we only cover enough to get you started. Nonetheless, someone who knows Scheme already should be able to use this chapter as the basis for writing and running small Chicken programs.
     128
     129@node Getting started - Scheme, Getting started - Chicken,  , Getting started
     130@section Scheme
     131
     132
     133Scheme is a member of the Lisp family of languages, of which Common Lisp and Emacs Lisp are the other two widely-known members. As with Lisp dialects, Scheme features
    81134
    82135@itemize
    83 @item Consing (creation of data on the heap) is relatively inexpensive, because a generational garbage collection scheme is used, in which short-lived data structures are reclaimed extremely quickly.
    84 
    85 @item Moreover, @code{call-with-current-continuation} is practically for free and CHICKEN does not suffer under any performance penalties if first-class continuations are used in complex ways.
     136@item a wide variety of programming paradigms, including imperative, functional, and object-oriented
     137
     138@item a very simple syntax, based upon nested parenthesization
     139
     140@item the ability to extend the language in meaningful and useful ways
     141
     142
     143@end itemize
     144In contrast to Common Lisp, Scheme is very minimal, and tries to include only those features absolutely necessary in programming. In contrast to Emacs Lisp, Scheme is not anchored into any one program (Emacs), and has a somewhat more modern language design.
     145
     146Scheme is defined in a document called @emph{The Revised^5 Report on the Algorithmic Language Scheme}, or @emph{R5RS} for short. (Yes, it really has been revised five times, so an expanded version of its name would be @emph{The Revised Revised Revised Revised Revised Report}.)  A newer report, @emph{R6RS}, was  released in 2007, but this report has attracted considerable controversy, and not all Scheme implementations will be made compliant with it. Chicken essentially complies with R5RS.
     147
     148Even though Scheme is consciously minimalist, it is recognized that a language must be more than a minimal core in order to be useful. Accordingly, the Scheme community uses a process known as `Scheme Requests For Implementation' (SRFI, pronounced `SUR-fee') to define new language features. A typical Scheme system therefore complies with one of the Scheme reports plus some or all of the accepted SRFIs.
     149
     150A good starting point for Scheme knowledge is @uref{http://www.schemers.org, http://www.schemers.org}. There you will find the defining reports, FAQs, lists of useful books and other resources, and the SRFIs.
     151
     152The Chicken community is at present developing tutorials for programmers who are new to Scheme but experienced with Python, Ruby, or other languages. These can be found on the Chicken wiki.
     153
     154@node Getting started - Chicken, Getting started - Chicken repositories; websites; and community, Getting started - Scheme, Getting started
     155@section Chicken
     156
     157
     158Chicken is an implementation of Scheme that has many advantages.
     159
     160<blockquote> Chicken Scheme combines an optimising compiler with a reasonably fast interpreter.  It supports almost all of R5RS and the important SRFIs. The compiler generates portable C code that supports tail recursion, first-class continuations, and lightweight threads, and the interface to and from C libraries is flexible, efficient, and easy to use.  There are hundreds of contributed Chicken libraries that make the programmer's task easier.  The interpreter allows interactive use, fast prototyping, debugging, and scripting.  The active and helpful Chicken community fixes bugs and provides support.  Extensive documentation is supplied. </blockquote>
     161
     162Chicken was developed by Felix L. Winkelmann over the period from 2000 through 2007. In early 2008, Felix asked the community to take over the responsibility of developing and maintaining the system, though he still takes a strong interest in it, and participates actively.
     163
     164Chicken includes
     165
     166@itemize
     167@item a Scheme interpreter that supports almost all of  R5RS Scheme, with   only a few relatively minor omissions, and with many extensions
     168
     169@item a compatible compiler whose target is C, thus making porting to new   machines and architectures relatively straightforward@itemize
     170@item the C support allows Scheme code to include `embedded' C code,   thus making it relatively easy to invoke host OS or library   functions
     171
     172
     173@end itemize
     174
     175
     176@item a framework for language extensions, library modules that broaden   the functionality of the system
     177
     178
     179@end itemize
     180This package is distributed under the @b{BSD license} and as such is free to use and modify.
     181
     182Scheme cognoscenti will appreciate the method of compilation and the design of the runtime-system, which follow closely Henry Baker's @uref{http://home.pipeline.com/~hbaker1/CheneyMTA.html, CONS Should Not CONS Its Arguments, Part II: Cheney on the M.T.A.} paper and expose a number of interesting properties.
     183
     184@itemize
     185@item Consing (creation of data on the heap) is relatively inexpensive,   because a generational garbage collection scheme is used, in which   short-lived data structures are reclaimed extremely quickly.
     186
     187@item Moreover, @code{call-with-current-continuation} is practically for free   and Chicken does not suffer under any performance penalties if   first-class continuations are used in complex ways.
    86188
    87189
     
    89191The generated C code is fully tail-recursive.
    90192
    91 Some of the features supported by CHICKEN:
     193Some of the features supported by Chicken:
    92194
    93195@itemize
    94 @item SRFIs 0, 1, 2, 4, 6-19, 23, 25-31, 37-40, 42, 43, 45, 47, 55, 57, 60-63, 66, 69, 72, 78, 85 and 95.
     196@item SRFIs 0, 1, 2, 4, 6-19, 23, 25-31, 37-40, 42, 43, 45, 47, 55, 57,   60-63, 66, 69, 72, 78, 85 and 95.
    95197
    96198@item Lightweight threads based on first-class continuations
     
    106208@item UNIX system calls and extended data structures
    107209
    108 @item Create interpreted or compiled shell scripts written in Scheme for UNIX or Windows
     210@item Create interpreted or compiled shell scripts written in Scheme for   UNIX or Windows
    109211
    110212@item Compiled C files can be easily distributed
     
    116218
    117219@end itemize
    118 This manual is merely a reference for the CHICKEN system and assumes a working knowledge of Scheme.
    119 
    120 The manual is split in the following sections:
    121 
    122 @table @b
    123 @item @ref{Basic mode of operation, Basic mode of operation}
    124 
    125 Compiling Scheme files.
    126 @item @ref{Using the compiler, Using the compiler}
    127 
    128 Explains how to use CHICKEN to compile programs and execute them.
    129 @item @ref{Using the interpreter, Using the interpreter}
    130 
    131 Invocation and usage of @code{csi}, the CHICKEN interpreter
    132 @item @ref{Supported language, Supported language}
    133 
    134 The language implemented by CHICKEN (deviations from the standard and extensions).
    135 @item @ref{Interface to external functions and variables, Interface to external functions and variables}
    136 
    137 Accessing C and C++ code and data.
    138 @item @ref{chicken-setup, chicken-setup}
    139 
    140 Packaging and installing extension libraries.
    141 @item @ref{Data representation, Data representation}
    142 
    143 How Scheme data is internally represented.
    144 @item @ref{Bugs and limitations, Bugs and limitations}
    145 
    146 Yes, there are some.
    147 @item @ref{FAQ, FAQ}
    148 
    149 A list of Frequently Asked Questions about CHICKEN (and their answers!).
    150 @item @ref{Acknowledgements, Acknowledgements}
    151 
    152 A list of some of the people that have contributed to make CHICKEN what it is.
    153 @item @ref{Bibliography, Bibliography}
    154 
    155 Links to documents that may be of interest.
    156 
    157 @end table
    158 @node Basic mode of operation, Using the compiler, The User's Manual, Top
     220Chicken has been used in many environments ranging from embedded systems through desktop machines to large-scale server deployments.   The number of language extensions, or @b{eggs}, will soon reach 400, including
     221
     222@itemize
     223@item extended language features
     224
     225@item development tools, such as documentation generators, debugging, and   automated testing libraries
     226
     227@item interfaces to other languages such as Java, Python, and Objective-C
     228
     229@item interfaces to database systems, GUIs, and other large-scale   libraries,
     230
     231@item network applications, such as servers and clients for ftp,   smtp/pop3, irc, and http
     232
     233@item web servers and related tools, including URL parsing, HTML   generation, AJAX, and HTTP session management
     234
     235@item data formats, including XML, JSON, and Unicode support
     236
     237
     238@end itemize
     239Chicken is supported by SWIG (Simplified Wrapper and Interface Generator), a tool that produces quick-and-dirty interface modules for C libraries (@uref{http://www.swig.org, http://www.swig.org}).
     240
     241This chapter provides you with an overview of the entire system, with enough information to get started writing and running small Scheme programs. Subsequent chapters cover
     242
     243@itemize
     244@item @ref{Basic mode of operation, Basic mode of operation}: Compiling Scheme files.
     245
     246@item @ref{Using the compiler, Using the compiler}: Explains how to use Chicken to compile   programs and execute them.
     247
     248@item @ref{Using the interpreter, Using the interpreter}: Invocation and usage of @code{csi}, the   Chicken interpreter
     249
     250@item @ref{Supported language, Supported language}: The language implemented by Chicken   (deviations from the standard and extensions).
     251
     252@item @ref{Interface to external functions and variables, Interface to external functions and variables}: Accessing C and   C++ code and data.
     253
     254@item @ref{chicken-setup, chicken-setup}: Packaging and installing extension libraries.
     255
     256@item @ref{Data representation, Data representation}: How Scheme data is internally represented.
     257
     258@item @ref{Bugs and limitations, Bugs and limitations}: Yes, there are some.
     259
     260@item @ref{FAQ, FAQ}: A list of Frequently Asked Questions about Chicken (and   their answers!).
     261
     262@item @ref{Acknowledgements, Acknowledgements}: A list of some of the people that have   contributed to make Chicken what it is.
     263
     264@item @ref{Bibliography, Bibliography}: Links to documents that may be of interest.
     265
     266
     267@end itemize
     268@node Getting started - Chicken repositories; websites; and community, Getting started - Installing Chicken, Getting started - Chicken, Getting started
     269@section Chicken repositories, websites, and community
     270
     271
     272At present, the URLs for Chicken information and download are somewhat confusing. It is envisaged that everything will eventually be accessible via the  domain @code{chicken-scheme.org}, but this hasn't been completely done.
     273
     274At present, the master Chicken website is @uref{http://www.call-with-current-continuation.org, http://www.call-with-current-continuation.org}. Here you can find basic information about Chicken, downloads, and pointers to other key resources.
     275
     276The Chicken wiki (@uref{http://chicken.wiki.br, http://chicken.wiki.br}) contains the most current version of the User's manual, along with various tutorials and other useful documents. The list of eggs is at @uref{http://chicken.wiki.br/Eggs%20Unlimited%203, http://chicken.wiki.br/Eggs%20Unlimited%203}.
     277
     278A very useful search facility for questions about Chicken is found at @uref{http://www.callcc.org, http://www.callcc.org}. The Chicken issue tracker is at @uref{http://trac.callcc.org, http://trac.callcc.org}.
     279
     280The Chicken community has two major mailing lists. If you are a Chicken user, @code{Chicken-Users} (@uref{http://lists.nongnu.org/mailman/listinfo/chicken-users, http://lists.nongnu.org/mailman/listinfo/chicken-users}) will be of interest. The crew working on the Chicken system itself uses the very low-volume @code{Chicken-Hackers} list (@uref{http://lists.nongnu.org/mailman/listinfo/chicken-hackers, http://lists.nongnu.org/mailman/listinfo/chicken-hackers}) for communication. 
     281
     282@node Getting started - Installing Chicken, Getting started - Development environments, Getting started - Chicken repositories; websites; and community, Getting started
     283@section Installing Chicken
     284
     285
     286Chicken is available in binary form for Windows and Linux/x86 systems, and in source form for all other platforms. Refer to the @code{README} file in the distribution for instructions on installing it on your system.
     287
     288Because it compiles to C, Chicken requires that a C compiler be installed on your system. (If you're not writing embedded C code, you can pretty much ignore the C compiler once you have installed it.)
     289
     290@itemize
     291@item On a Linux system, the GNU Compiler Collection (@code{gcc}) should be   installed as part of the basic operating system, or should be   available through the package management system (e.g., APT,   Synaptic, RPM, or Yum, depending upon your Linux distribution).
     292
     293@item On Macintosh OS X, you will need the XCode tools, which are shipped   on the OS X DVD with recent versions of the operating system.
     294
     295@item On Windows, you have three choices.@itemize
     296@item Cygwin (@uref{http://sources.redhat.com/cygwin, http://sources.redhat.com/cygwin}) provides a relatively   full-featured Unix environment for Windows.  Chicken works   substantially the same in Cygwin and Unix.
     297
     298@item The GNU Compiler Collection has been ported to Windows, in the   MinGW system (@uref{http://mingw.sourceforge.net, http://mingw.sourceforge.net}). Unlike Cygwin,   executables produced with MinGW do not need the Cygwin DLLs in order   to run.   MSys is a companion package to MinGW; it provides a minimum   Unix-style development/build environment, again ported from free   software.@itemize
     299@item You can build Chicken either with MinGW alone or with MinGW plus    MSys. Both approaches produce a Chicken built against the mingw headers    and import libraries.   The only difference is the environment where you actually run make.   @code{Makefile.mingw} is can be used in @code{cmd.exe} with the version of make   that comes with mingw.  @code{Makefile.mingw-msys}    uses unix commands such as @code{cp} and @code{rm}.  The end product is the   same.
     300
     301
     302@end itemize
     303
     304
     305@item Microsoft Visual Studio will soon be supported, including the   Express edition, which is a non-free but no-cost compiler suite   available from Microsoft   (@uref{http://www.microsoft.com/express/vc, http://www.microsoft.com/express/vc}). Chicken supports   command-line building using the command-line C/C++ compiler.@itemize
     306@item Visual   Studio users will want to install the Unix Utilities, available at   @uref{http://www.call-with-current-continuation.org/tarballs/UnxUtils.zip, http://www.call-with-current-continuation.org/tarballs/UnxUtils.zip},   in order to get suitable versions of @code{make}, @code{tar}, @code{gzip}, and   similar commands.
     307
     308
     309@end itemize
     310
     311
     312
     313@end itemize
     314
     315
     316
     317@end itemize
     318Refer to the @code{README} file for the version you're installing for more information on the installation process.
     319
     320@node Getting started - Development environments, Getting started - The Read-Eval-Print loop, Getting started - Installing Chicken, Getting started
     321@section Development environments
     322
     323
     324The simplest development environment is a text editor and terminal window (Windows: Command Prompt, OSX: Terminal, Linux/Unix: xterm) for using the interpreter and/or calling the compiler. If you @uref{http://chicken.wiki.br/readline, install the @code{readline} egg}, you have all the benefits of command history in the interpreter, Emacs or vi-compatible line editing, and customization.
     325
     326You will need a text editor that knows Scheme; it's just too painful with editors that don't do parenthesis matching and proper indentation. Some editors allow you to execute Scheme code directly in the editor. This makes programming very interactive: you can type in a function and then try it right away. This feature is very highly recommended.
     327
     328As programmers have very specific tastes about editors, the editors listed here are shown in alphabetic order. We aren't about to tell you which editor to use, and there may be editors not shown here that might satisfy your needs. We would be very interested in reports of other editors that have been used with Chicken, especially those that support interactive evaluation of forms during editing. Pointers to these (and to any editor customization files appropriate) should be put on the Chicken wiki, and will likely be added to future editions of this manual. (We have had a request for editors that support proportional fonts, in particular.)
     329
     330@itemize
     331@item Emacs (@uref{http://www.gnu.org/software/emacs, http://www.gnu.org/software/emacs}) is an extensible, customizable, self-documenting editor available for Linux/Unix, Macintosh, and Windows systems; CHICKEN provides Emacs support out of the box, with the @code{hen.el} Emacs Lisp file. Consult the `Emacs Guide for Chicken Users' (which will be available on the Chicken Wiki soon) for information on setting up and using Emacs with Chicken.
     332
     333@item Epsilon (@uref{http://www.lugaru.com, http://www.lugaru.com}) is a commercial (proprietary) text editor whose design was inspired by Emacs. Although Scheme support isn't provided, a Lisp mode is available on Lugaru's FTP site, and could with some work be made to duplicate the Emacs support.
     334
     335@item SciTE (@uref{http://scintilla.sourceforge.net/SciTE.html, http://scintilla.sourceforge.net/SciTE.html}),  unlike Emacs or Vim, follows typical graphical UI design conventions and control-key mappings, and for simple tasks is as familiar and easy to use as Notepad, KEdit, TeachText etc.  However it has many programming features such as multiple open files, syntax highlighting for a large number of languages (including Lisps), matching of brackets, ability to fold sections of code based on the matched brackets, column selections, comment/uncomment, and the ability to run commands in the same directory as the current file (such as make, grep, etc.)  SciTE is written with the GTK toolkit and is portable to any GTK platform, including Windows, Linux and MacOS.  It uses the Scintilla text-editing component, which lends itself well to embedding within other IDEs and graphical toolkits. It does not have any other Scheme-specific features, but being open-source and modular, features like auto-formatting of S-expressions could be added.  The syntax highlighting can be configured to use different fonts for different types of syntax, including proportional fonts.
     336
     337@item Vim (@uref{http://www.vim.org, http://www.vim.org}) is a highly configurable text editor built to enable efficient and fast text editing. It is an improved version of the vi editor distributed with most UNIX systems. Vim comes with generic Lisp (and therefore Scheme) editing capabilities out of the box. A few tips on using Vim with Chicken can be found at  @uref{http://cybertiggyr.com/gene/15-vim/, http://cybertiggyr.com/gene/15-vim/}.
     338
     339
     340@end itemize
     341In the rest of this chapter, we'll assume that you are using an editor of your choice and a regular terminal window for executing your Chicken code.
     342
     343@node Getting started - The Read-Eval-Print loop, Getting started - The compiler, Getting started - Development environments, Getting started
     344@section The Read-Eval-Print loop
     345
     346@menu
     347* Getting started - The Read-Eval-Print loop - Scripts::
     348
     349@end menu
     350
     351
     352To invoke the Chicken interpreter, you use the @code{csi} command.
     353
     354@verbatim
     355$ csi
     356CHICKEN
     357(c)2008 The Chicken Team
     358(c)2000-2007 Felix L. Winkelmann
     359Version 3.1.2 - macosx-unix-gnu-x86     [ manyargs dload ptables applyhook ]
     360SVN rev. 10185  compiled 2008-03-27 on argyre.local (Darwin)
     361#;1>
     362@end verbatim
     363This brings up a brief banner, and then the prompt. You can use this pretty much like any other Scheme system, e.g.,
     364
     365@verbatim
     366#;1> (define (twice f) (lambda (x) (f (f x))))
     367#;2> ((twice (lambda (n) (* n 10))) 3)
     368300
     369@end verbatim
     370Suppose  we have already created a file @code{fact.scm} containing a  function definition.
     371
     372@verbatim
     373(define (fact n)
     374  (if (= n 0)
     375      1
     376      (* n (fact (- n 1)))))
     377@end verbatim
     378We can now load this file and try out the function.
     379
     380@verbatim
     381#;3> (load "fact.scm")
     382; loading fact.scm ...
     383#;4> (fact 3)
     3846
     385@end verbatim
     386The @b{read-eval-print loop} (@b{REPL}) is the component of the Scheme system that @emph{reads} a Scheme expression, @emph{eval}uates it, and @emph{prints} out the result. The REPL's prompt can be customized (see the @uref{http:Using%20the%20interpreter, `Using the Interpreter'}) but the default prompt, showing the number of the form, is quite convenient.
     387
     388The REPL also supports debugging commands:  input lines beginning with a @code{,} (comma) are treated as special commands. (See the @ref{Using the interpreter - Toplevel commands, full list}.) We can @b{trace} @code{fact} to see how it works.
     389
     390@verbatim
     391#;5> ,tr fact
     392#;5> (fact 3)
     393|(fact 3)
     394| (fact 2)
     395|  (fact 1)
     396|   (fact 0)
     397|   fact -> 1
     398|  fact -> 1
     399| fact -> 2
     400|fact -> 6
     4016
     402@end verbatim
     403The command number didn't increment, because the @code{tr} command isn't actually a Scheme @emph{form}.
     404
     405@node Getting started - The Read-Eval-Print loop - Scripts,  ,  , Getting started - The Read-Eval-Print loop
     406@subsection Scripts
     407
     408
     409You can use the interpreter to run a Scheme program from the command line. Here we create a program that does a quick search-and-replace on an input file; the arguments are a regular expression and a replacement string.
     410
     411@verbatim
     412$ cat quickrep.dat
     413xyzabcghi
     414abxawxcgh
     415foonly
     416$ csi -ss quickrep.scm <quickrep.dat 'a.*c' A
     417xyzAghi
     418Agh
     419foonly
     420@end verbatim
     421The @code{-ss} option sets several options that work smoothly together to execute a script. You can make the command directly executable from the shell by inserting a `@ref{Using the interpreter - Writing Scheme scripts, shebang line}' at the beginning of the program.
     422
     423@code{regex}, the regular expression library, is one of the libraries included with Chicken.
     424
     425@verbatim
     426(use regex)
     427(define (process-line line re rplc)
     428  (string-substitute re rplc line 'all))
     429(define (quickrep re rplc)
     430  (let ((line (read-line)))
     431    (if (not (eof-object? line))
     432        (begin
     433          (display (process-line line re rplc))
     434          (newline)
     435          (quickrep re rplc)))))
     436;;; Does a lousy job of error checking!
     437(define (main args)
     438  (quickrep (regexp (car args)) (cadr args)))
     439@end verbatim
     440The @code{-ss} option arranges to call a procedure named @code{main}, with the command line arguments, packed in a list, as its arguments. (There are a number of ways this program could be made more idiomatic Chicken Scheme, see the rest of the manual for details.)
     441
     442@node Getting started - The compiler, Getting started - Installing an egg, Getting started - The Read-Eval-Print loop, Getting started
     443@section The compiler
     444
     445
     446There are several reasons you might want to compile your code.
     447
     448@itemize
     449@item Compiled code executes substantially faster than interpreted   code.
     450
     451@item You might want to deploy an application onto machines where the   users aren't expected to have Chicken installed: compiled   applications can be self-contained.
     452
     453
     454@end itemize
     455The Chicken compiler is provided as the command @code{chicken}, but in almost all cases, you will want to use the @code{csc} command instead. @code{csc} is a convenient driver that automates compiling Scheme programs into C, compiling C code into object code, and linking the results into an executable file. (Note: in a Windows environment with Visual Studio, you may find that @code{csc} refers to Microsoft's C# compiler. There are a number of ways of sorting this out, of which the simplest is to rename one of the two tools, and/or to  organize your @code{PATH} according to the task at hand.)
     456
     457Compiled code can be intermixed with interpreted code on systems that support dynamic loading, which includes modern versions of *BSD, Linux, Mac OS X, Solaris, and Windows.
     458
     459We can compile our factorial function, producing a file named @code{fact.so} (`shared object' in Linux-ese, the same file type is used in OS X and Windows, rather than @code{dylib} or @code{dll}, respectively).
     460
     461@verbatim
     462chicken$ csc -dynamic fact.scm
     463chicken$ csi -quiet
     464#;1> (load "fact.so")
     465; loading fact.so ...
     466#;2> (fact 6)
     467720
     468@end verbatim
     469On any system, we can just compile a program directly into an executable. Here's a program that tells you whether its argument is a palindrome.
     470
     471@verbatim
     472(define (palindrome? x)
     473  (define (check left right)
     474    (if (>= left right)
     475        #t
     476        (and (char=? (string-ref x left) (string-ref x right))
     477             (check (add1 left) (sub1 right)))))
     478  (check 0 (sub1 (string-length x))))
     479(let ((arg (car (command-line-arguments))))
     480  (display
     481   (string-append arg
     482                  (if (palindrome? arg)
     483                      " is a palindrome\n"
     484                      " isn't a palindrome\n"))))
     485 
     486@end verbatim
     487We can compile this program using @code{csc}, creating an executable named @code{palindrome}.
     488
     489@verbatim
     490$ csc -o palindrome palindrome.scm
     491$ ./palindrome level
     492level is a palindrome
     493$ ./palindrome liver
     494liver isn't a palindrome
     495@end verbatim
     496Chicken supports separate compilation, using some extensions to Scheme. Let's divide our palindrome program into a library module (@code{pal-proc.scm}) and a client module (@code{pal-user.scm}).
     497
     498Here's the external library. We @code{declare} that @code{pal-proc} is a `unit', which is the basis of separately-compiled modules in Chicken. (Units deal with separate compilation, but don't involve separated namespaces; namespaced module systems are available as eggs.)
     499
     500@verbatim
     501;;; Library pal-proc.scm
     502(declare (unit pal-proc))
     503(define (palindrome? x)
     504  (define (check left right)
     505    (if (>= left right)
     506        #t
     507        (and (char=? (string-ref x left) (string-ref x right))
     508             (check (add1 left) (sub1 right)))))
     509  (check 0 (sub1 (string-length x))))
     510@end verbatim
     511Next we have some  client code that `uses' this separately-compiled module. 
     512
     513@verbatim
     514;;; Client pal-user.scm
     515(declare (uses pal-proc))
     516(let ((arg (car (command-line-arguments))))
     517  (display
     518   (string-append arg
     519                  (if (palindrome? arg)
     520                      " is a palindrome\n"
     521                      " isn't a palindrome\n"))))
     522@end verbatim
     523Now we can compile and link everything together. (We show the compile and link operations separately, but they can of course be combined into one command.)
     524
     525@verbatim
     526$ csc -c pal-proc.scm
     527$ csc -c pal-user.scm
     528$ csc -o pal-separate pal-proc.o pal-user.o
     529$ ./pal-separate level
     530level is a palindrome
     531@end verbatim
     532@node Getting started - Installing an egg, Getting started - Accessing C libraries, Getting started - The compiler, Getting started
     533@section Installing an egg
     534
     535
     536Installing eggs is quite straightforward on systems that support dynamic loading (again, that would include *BSD, Linux, Mac OS X, Solaris, and Windows).  The command @code{chicken-setup} will fetch an egg from the master Chicken repository, and install it on your local system.
     537
     538In this example, we install the @code{uri} egg, for parsing Uniform Resource Identifiers. The installation produces a lot of output, which we have edited for space reasons.
     539
     540@verbatim
     541$ chicken-setup uri
     542@end verbatim
     543@verbatim
     544The extension uri does not exist.
     545Do you want to download it ? (yes/no/abort) [yes] yes
     546downloading uri.egg from (www.call-with-current-continuation.org eggs/3 80)
     547  gzip -d -c ../uri.egg | tar xf -
     548.  /Users/vmanis/local/bin/csc -feature compiling-extension
     549     -s -O2 -d1 uri.scm -o uri.so -check-imports -emit-exports uri.exports
     550... (lots of stuff elided)
     551.  rm -fr /Users/vmanis/project/chicken/uri.egg
     552@end verbatim
     553First, @code{chicken-setup} asks us if we want to download the egg. It then uncompresses the egg, compiles the code, and installs the egg in the local Chicken repository.
     554
     555Now we can use our new egg.
     556
     557@verbatim
     558#;1> (use uri)
     559; loading /Users/vmanis/local/lib/chicken/3/uri.so ...
     560; loading /Users/vmanis/local/lib/chicken/3/coerce-support.so ...
     561; loading /Users/vmanis/local/lib/chicken/3/misc-extn-list-support.so ...
     562; loading /Users/vmanis/local/lib/chicken/3/synch-support.so ...
     563; loading /Users/vmanis/local/lib/chicken/3/lookup-table.so ...
     564; loading /Users/vmanis/local/lib/chicken/3/misc-extn-control-support.so ...
     565#;2> (uri-host (uri "uref{http://www.foobar.org/blah, http://www.foobar.org/blah}"))
     566"www.foobar.org"
     567@end verbatim
     568@node Getting started - Accessing C libraries,  , Getting started - Installing an egg, Getting started
     569@section Accessing C libraries
     570
     571
     572Because Chicken compiles to C, and because a foreign function interface is built into the compiler, interfacing to a C library is quite straightforward. This means that nearly any facility available on the host system is accessible from Chicken, with more or less work.
     573
     574Let's create a simple C library, to demonstrate how this works. Here we have a function that will compute and return the @b{n}th Fibonacci number. (This isn't a particularly good use of C here, because we could write this function just as easily in Scheme, but a real example would take far too much space here.)
     575
     576@verbatim
     577int fib(int n) {
     578  int prev = 0, curr = 1;
     579  int next;
     580  int i;
     581  for (i = 0; i < n; i++) {
     582    next = prev + curr;
     583    prev = curr;
     584    curr = next;
     585  }
     586  return curr;
     587}
     588@end verbatim
     589Now we can call this function from Chicken.
     590
     591@verbatim
     592#>
     593  extern fib(int n);
     594<#
     595(define xfib (foreign-lambda int "fib" int))
     596(do ((i 0 (+ i 1))) ((> i 10))
     597  (printf "~A " (xfib i)))
     598(newline)
     599@end verbatim
     600The syntax @code{#>...<#} allows you to include literal C (typically external declarations) in your Chicken code. We access @code{fib} by defining a @code{foreign-lambda} for it, in this case saying that the function takes one integer argument (the @code{int} after the function name), and that it returns an integer result (the @code{int} before.) Now we can invoke @code{xfib} as though it were an ordinary Scheme function.
     601
     602@verbatim
     603$ gcc -c fib.c
     604$ csc -o fib-user fib.o fib-user.scm
     605$ ./fib-user
     6060 1 1 2 3 5 8 13 21 34 55
     607@end verbatim
     608Those who are interfacing to substantial C libraries should consider using the  easyffi egg, or SWIG.
     609
     610Back to @ref{The User's Manual, The User's Manual} Next: @ref{Using the compiler, Using the compiler}
     611
     612@node Basic mode of operation, Using the compiler, Getting started, Top
    159613@chapter Basic mode of operation
    160614
     
    164618The most portable way of creating separately linkable entities is supported by so-called @emph{unit}s.  A unit is a single compiled object module that contains a number of toplevel expressions that are executed either when the unit is the @emph{main} unit or if the unit is @emph{used}.  To use a unit, the unit has to be @emph{declare}ed as used, like this:
    165619
    166 <enscript highlight=scheme> (declare (uses UNITNAME)) </enscript>
    167 
     620@example
     621(declare (uses UNITNAME))
     622@end example
    168623The toplevel expressions of used units are executed in the order in which the units appear in the @code{uses} declaration. Units may be used multiple times and @code{uses} declarations may be circular (the unit is initialized at most once).  To compile a file as a unit, add a @code{unit} declaration:
    169624
    170 <enscript highlight=scheme> (declare (unit UNITNAME)) </enscript>
    171 
     625@example
     626(declare (unit UNITNAME))
     627@end example
    172628When compiling different object modules, make sure to have one main unit. This unit is called initially and initializes all used units before executing its toplevel expressions. The main-unit has no @code{unit} declaration.
    173629
    174630Another method of using definitions in separate source files is to @emph{include} them. This simply inserts the code in a given file into the current file:
    175631
    176 <enscript highlight=scheme> (include "FILENAME") </enscript>
    177 
     632@example
     633(include @strong{"FILENAME"})
     634@end example
    178635Macro definitions are only available when processed by @code{include} or @code{require-for-syntax}. Macro definitions in separate units are not available, since they are defined at compile time, i.e the time when that other unit was compiled (macros can optionally be available at runtime, see @code{define-macro} in @ref{Non-standard macros and special forms, Substitution forms and macros}).
    179636
    180637On platforms that support dynamic loading of compiled code ( Windows, most ELF based systems like Linux or BSD, MacOS X, and others) code can be compiled into a shared object @code{.dll}, @code{.so}, @code{.dylib}) and loaded  dynamically into a running application.
    181638
    182 Previous: @ref{The User's Manual, The User's Manual} Next: @ref{Using the compiler, Using the compiler} 
     639Previous: @ref{Getting started, Getting started} Next: @ref{Using the compiler, Using the compiler} 
    183640
    184641@node Using the compiler, Using the interpreter, Basic mode of operation, Top
     
    207664
    208665@verbatim
    209 chicken FILENAME @{OPTION@}
     666chicken FILENAME {OPTION}
    210667@end verbatim
    211668@code{FILENAME} is the complete pathname of the source file that is to be translated into C. A filename argument of @code{-} specifies that the source text should be read from standard input. Note that the filename has to be the first argument to @code{chicken}.
     
    232689
    233690Aborts compilation process after macro-expansion and syntax checks.
    234 @item -compress-literals THRESHOLD
    235 
    236 Compiles quoted literals that exceed the size @code{THRESHOLD} as strings and parse the strings at run-time. This reduces the size of the code and speeds up compile-times of the host C compiler, but has a small run-time performance penalty. The size of a literal is computed by counting recursively the objects in the literal, so a vector counts as 1 plus the count of the elements, a pair counts as the counts of the car and the cdr, respectively. All other objects count 1.
    237691@item -debug MODES
    238692
     
    355809@item -include-path PATHNAME
    356810
    357 Specifies an additional search path for files included via the @code{include} special form. This option may be given multiple times. If the environment variable @code{CHICKEN_INCLUDE_PATH} is set, it should contain a list of alternative include pathnames separated by @code{;}. The environment variable @code{CHICKEN_HOME} is also considered as a search path.
     811Specifies an additional search path for files included via the @code{include} special form. This option may be given multiple times. If the environment variable @code{CHICKEN_INCLUDE_PATH} is set, it should contain a list of alternative include pathnames separated by @code{;}.
    358812@item -inline
    359813
     
    361815@item -inline-limit THRESHOLD
    362816
    363 Sets the maximum size of a potentially inlinable procedure. This option is only effective when inlining has been enabled with the @code{-inline} option. The default threshold is @code{10}.
     817Sets the maximum size of a potentially inlinable procedure. The default threshold is @code{10}.
    364818@item -keyword-style STYLE
    365819
     
    534988
    535989@menu
    536 * Using the compiler - Examples - A simple example (with one source file)::
     990* Using the compiler - Examples - A simple example ;with one source file;::
    537991* Using the compiler - Examples - An example with multiple files::
    538992
     
    540994
    541995
    542 @node Using the compiler - Examples - A simple example (with one source file), Using the compiler - Examples - An example with multiple files,  , Using the compiler - Examples
     996@node Using the compiler - Examples - A simple example ;with one source file;, Using the compiler - Examples - An example with multiple files,  , Using the compiler - Examples
    543997@subsection A simple example (with one source file)
    544998
    545999@menu
    546 * Using the compiler - Examples - A simple example (with one source file) - Writing your source file::
    547 * Using the compiler - Examples - A simple example (with one source file) - Compiling your program::
    548 * Using the compiler - Examples - A simple example (with one source file) - Running your program::
     1000* Using the compiler - Examples - A simple example ;with one source file; - Writing your source file::
     1001* Using the compiler - Examples - A simple example ;with one source file; - Compiling your program::
     1002* Using the compiler - Examples - A simple example ;with one source file; - Running your program::
    5491003
    5501004@end menu
     
    5531007To compile a Scheme program (assuming a UNIX-like environment) consisting of a single source file, perform the following steps.
    5541008
    555 @node Using the compiler - Examples - A simple example (with one source file) - Writing your source file, Using the compiler - Examples - A simple example (with one source file) - Compiling your program,  , Using the compiler - Examples - A simple example (with one source file)
     1009@node Using the compiler - Examples - A simple example ;with one source file; - Writing your source file, Using the compiler - Examples - A simple example ;with one source file; - Compiling your program,  , Using the compiler - Examples - A simple example ;with one source file;
    5561010@subsubsection Writing your source file
    5571011
     
    5591013In this example we will assume your source file is called @code{foo.scm}:
    5601014
    561 <enscript highlight=scheme> ;;; foo.scm
    562 
    563 (define (fac n)
    564 
    565 @verbatim
    566  (if (zero? n)
    567      1
    568      (* n (fac (- n 1))) ) )
    569 @end verbatim
    570 (write (fac 10)) (newline) </enscript>
    571 
    572 @node Using the compiler - Examples - A simple example (with one source file) - Compiling your program, Using the compiler - Examples - A simple example (with one source file) - Running your program, Using the compiler - Examples - A simple example (with one source file) - Writing your source file, Using the compiler - Examples - A simple example (with one source file)
     1015@example
     1016@emph{;;; foo.scm
     1017}
     1018(@strong{define} (@strong{fac} n)
     1019  (@strong{if} (zero? n)
     1020      1
     1021      (* n (fac (- n 1))) ) )
     1022
     1023(write (fac 10))
     1024(newline)
     1025@end example
     1026@node Using the compiler - Examples - A simple example ;with one source file; - Compiling your program, Using the compiler - Examples - A simple example ;with one source file; - Running your program, Using the compiler - Examples - A simple example ;with one source file; - Writing your source file, Using the compiler - Examples - A simple example ;with one source file;
    5731027@subsubsection Compiling your program
    5741028
     
    5851039foo  foo.scm
    5861040@end verbatim
    587 @node Using the compiler - Examples - A simple example (with one source file) - Running your program,  , Using the compiler - Examples - A simple example (with one source file) - Compiling your program, Using the compiler - Examples - A simple example (with one source file)
     1041@node Using the compiler - Examples - A simple example ;with one source file; - Running your program,  , Using the compiler - Examples - A simple example ;with one source file; - Compiling your program, Using the compiler - Examples - A simple example ;with one source file;
    5881042@subsubsection Running your program
    5891043
     
    5971051If you get a @code{foo: command not found} error, you might want to try with @code{./foo} instead (or, in Unix machines, modify your @code{PATH} environment variable to include your current directory).
    5981052
    599 @node Using the compiler - Examples - An example with multiple files,  , Using the compiler - Examples - A simple example (with one source file), Using the compiler - Examples
     1053@node Using the compiler - Examples - An example with multiple files,  , Using the compiler - Examples - A simple example ;with one source file;, Using the compiler - Examples
    6001054@subsection An example with multiple files
    6011055
     
    6171071The declarations in these files specify which of the compiled files is the main module, and which is the library module. An executable can only have one main module, since a program has only a single entry-point. In this case @code{foo.scm} is the main module, because it doesn't have a @code{unit} declaration:
    6181072
    619 <enscript highlight=scheme> ;;; foo.scm
    620 
    621 @table @b
    622 @item The declaration marks this source file as dependant on the symbols provided
    623 
    624 
    625 @item by the bar unit
    626 
    627 
    628 
    629 @end table
    630 (declare (uses bar))
    631 
    632 (write (fac 10)) (newline) </enscript>
    633 
     1073@example
     1074@emph{;;; foo.scm
     1075}
     1076@emph{; The declaration marks this source file as dependant on the symbols provided
     1077}@emph{; by the bar unit:
     1078}(declare (uses bar))
     1079
     1080(write (fac 10)) (newline)
     1081@end example
    6341082@code{bar.scm} will be our library:
    6351083
    636 <enscript highlight=scheme> ;;; bar.scm
    637 
    638 @table @b
    639 @item The declaration marks this source file as the bar unit.  The names of the
    640 
    641 
    642 @item units and your files don't need to match.
    643 
    644 
    645 
    646 @end table
    647 (declare (unit bar))
    648 
    649 (define (fac n)
    650 
    651 @verbatim
    652  (if (zero? n)
    653      1
    654      (* n (fac (- n 1))) ) )
    655 @end verbatim
    656 </enscript>
    657 
     1084@example
     1085@emph{;;; bar.scm
     1086}
     1087@emph{; The declaration marks this source file as the bar unit.  The names of the
     1088}@emph{; units and your files don't need to match.
     1089}(declare (unit bar))
     1090
     1091(@strong{define} (@strong{fac} n)
     1092  (@strong{if} (zero? n)
     1093      1
     1094      (* n (fac (- n 1))) ) )
     1095@end example
    6581096@node Using the compiler - Examples - An example with multiple files - Compiling and running your program,  , Using the compiler - Examples - An example with multiple files - Writing your source files, Using the compiler - Examples - An example with multiple files
    6591097@subsubsection Compiling and running your program
     
    7201158It is relatively easy to create distributions of Scheme projects that have been compiled to C.  The runtime system of CHICKEN consists of only two handcoded C files (@code{runtime.c} and @code{chicken.h}), plus the file @code{chicken-config.h}, which is generated by the build process. All other modules of the runtime system and the extension libraries are just compiled Scheme code. The following example shows a minimal application, which should run without changes on the most frequent operating systems, like Windows, Linux or FreeBSD:
    7211159
    722 Let's take a simple "Hello, world!":
    723 
    724 <enscript highlight=scheme> ; hello.scm
    725 
    726 (print "Hello, world!") </enscript>
    727 
     1160Let's take a simple example.
     1161
     1162@example
     1163@emph{; hello.scm
     1164}
     1165(print @strong{"Hello, world!"})
     1166@end example
     1167@verbatim
     1168 % chicken hello.scm -optimize-level 3 -output-file hello.c
     1169@end verbatim
    7281170Compiled to C, we get @code{hello.c}. We need the files @code{chicken.h} and @code{runtime.c}, which contain the basic runtime system, plus the three basic library files @code{library.c}, @code{eval.c} and @code{extras.c} which contain the same functionality as the library linked into a plain CHICKEN-compiled application, or which is available by default in the interpreter, @code{csi}:
    7291171
    7301172@verbatim
    731 % csc hello.scm -O2 -d1
    732 @end verbatim
    733 A simple makefile is needed as well:
    734 
    735 <enscript highlight=makefile>
    736 
    737 @enumerate
    738 @item Makefile for UNIX systems
    739 
    740 
    741 @end enumerate
    742 hello: hello.o runtime.o library.o eval.o extras.o
    743 
    744 @verbatim
    745       $(CC) -o hello hello.o runtime.o library.o eval.o extras.o -lm
    746 @end verbatim
    747 hello.o: chicken.h runtime.o: chicken.h library.o: chicken.h eval.o: chicken.h extras.o: chicken.h </enscript>
    748 
     1173 % cd /tmp
     1174 %echo '(print "Hello World.")' > hello.scm
     1175 % cp $CHICKEN_BUILD/runtime.c .
     1176 % cp $CHICKEN_BUILD/library.c .
     1177 % cp $CHICKEN_BUILD/eval.c    .
     1178 % cp $CHICKEN_BUILD/extras.c  .
     1179 % gcc -static -Os -fomit-frame-pointer runtime.c library.c eval.c \
     1180   extras.c hello.c -o hello -lm
     1181@end verbatim
    7491182Now we have all files together, and can create an tarball containing all the files:
    7501183
     
    7531186% gzip hello.tar
    7541187@end verbatim
    755 This is of naturally rather simplistic. Things like enabling dynamic loading, estimating the optimal stack-size and selecting supported features of the host system would need more configuration- and build-time support. All this can be addressed using more elaborate build-scripts, makefiles or by using autoconf/automake.
     1188This is naturally rather simplistic. Things like enabling dynamic loading, estimating the optimal stack-size and selecting supported features of the host system would need more configuration- and build-time support. All this can be addressed using more elaborate build-scripts, makefiles or by using autoconf/automake.
    7561189
    7571190Note also that the size of the application can still be reduced by removing @code{extras} and @code{eval} and compiling @code{hello.scm} with the @code{-explicit-use} option.
     
    8021235
    8031236Evaluate @code{EXPRESSIONS}. This option implies @code{-batch} and @code{-quiet}, so no startup message will be printed and the interpreter exits after processing all @code{-eval} options and/or loading files given on the command-line.
     1237@item -p  -print EXPRESSIONS
     1238
     1239Evaluate @code{EXPRESSIONS} and print the results of each expression using @code{print}. Implies @code{-batch} and @code{-quiet}.
     1240@item -P  -pretty-print EXPRESSIONS
     1241
     1242Evaluate @code{EXPRESSIONS} and print the results of each expression using @code{pretty-print}. Implies @code{-batch} and @code{-quiet}.
    8041243@item -D  -feature SYMBOL
    8051244
    806 Registers @code{SYMBOL} to be a valid feature identifier for @code{cond-expand}.
     1245Registers @code{SYMBOL} to be a valid feature identifier for @code{cond-expand} and @code{feature?}.
    8071246@item -h  -help
    8081247
     
    8101249@item -I  -include-path PATHNAME
    8111250
    812 Specifies an alternative search-path for files included via the @code{include} special form. This option may be given multiple times. If the environment variable @code{CHICKEN_INCLUDE_PATH} is set, it should contain a list of alternative include pathnames separated by @code{;}. The environment variable @code{CHICKEN_HOME} is also considered as a search path.
     1251Specifies an alternative search-path for files included via the @code{include} special form. This option may be given multiple times. If the environment variable @code{CHICKEN_INCLUDE_PATH} is set, it should contain a list of alternative include pathnames separated by @code{;}.
    8131252@item -k  -keyword-style STYLE
    8141253
     
    8221261@item -q  -quiet
    8231262
    824 Do not print a startup message.
     1263Do not print a startup message. Also disables generation of call-trace information for interpreted code.
    8251264@item -s  -script PATHNAME
    8261265
     
    8631302@verbatim
    8641303C:>type foo.bat
    865 @@;csibatch %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
     1304@;csibatch %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
    8661305(print (eval (with-input-from-string
    8671306                (car (command-line-arguments))
     
    9411380
    9421381@end table
    943 <enscript highlight=scheme>
    944 
    945 @enumerate
    946 @item ;1> (fac 10)                       ==> 3628800
    947 
    948 @item ;2> ,tr fac
    949 
    950 @item ;3> (fac 3) |(fac 3) | (fac 2) |  (fac 1) |   (fac 0) |   fac -> 1  |  fac -> 1  | fac -> 2  |fac -> 6                          ==> 6
    951 
    952 @item ;4> ,utr fac
    953 
    954 @item ;5> (fac 3)                        ==> 6 </enscript>
    955 
    956 
    957 @end enumerate
     1382@example
     1383#@emph{;1> (fac 10)                       ==> 3628800
     1384}#@emph{;2> ,tr fac
     1385}#@emph{;3> (fac 3)
     1386}|(fac 3)
     1387| (fac 2)
     1388|  (fac 1)
     1389|   (fac 0)
     1390|   fac -> 1
     1391|  fac -> 1
     1392| fac -> 2
     1393|fac -> 6                          =@strong{=>} 6
     1394#@emph{;4> ,utr fac
     1395}#@emph{;5> (fac 3)                        ==> 6
     1396}@end example
     1397k
     1398
    9581399@table @b
    9591400@item ,utr SYMBOL ...
     
    10111452@verbatim
    10121453#;1> (define-record point x y)
    1013 #;2> (set-describer! 'point (lambda (pt o) (print "a point with x=" (point-x pt) " and y=" (point-y pt))))
     1454#;2> (set-describer! 'point
     1455       (lambda (pt o)
     1456         (print "a point with x=" (point-x pt) " and y=" (point-y pt))))
    10141457#;3> ,d (make-point 1 2)
    10151458a point with x=1 and y=2
     
    10261469(use readline regex)
    10271470(current-input-port (make-gnu-readline-port))
    1028 (gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history"))
     1471(gnu-history-install-file-manager
     1472  (string-append (or (getenv "HOME") ".") "/.csi.history"))
    10291473@end verbatim
    10301474More details are available in @uref{http://www.call-with-current-continuation.org/eggs/readline.html, the egg's documentation}.
     
    10771521@item @ref{Parameters, Parameters}
    10781522
    1079 @item @ref{Unit library, Unit library} basic Scheme definitions
    1080 
    1081 @item @ref{Unit eval, Unit eval} evaluation and macro-handling
    1082 
    1083 @item @ref{Unit extras, Unit extras} useful utility definitions
    1084 
    1085 @item @ref{Unit srfi-1, Unit srfi-1} List Library
     1523@item @ref{Unit library, Unit library} Basic Scheme definitions
     1524
     1525@item @ref{Unit eval, Unit eval} Evaluation and macro-handling
     1526
     1527@item @ref{Unit extras, Unit extras} Useful utility definitions
     1528
     1529@item @ref{Unit srfi-1, Unit srfi-1} List library
    10861530
    10871531@item @ref{Unit srfi-4, Unit srfi-4} Homogeneous numeric vectors
     
    10891533@item @ref{Unit srfi-13, Unit srfi-13} String library
    10901534
    1091 @item @ref{Unit srfi-14, Unit srfi-14} character set library
    1092 
    1093 @item @ref{Unit match, Unit match} pattern matching runtime-support
    1094 
    1095 @item @ref{Unit regex, Unit regex} regular expressions
    1096 
    1097 @item @ref{Unit srfi-18, Unit srfi-18} multithreading
     1535@item @ref{Unit srfi-14, Unit srfi-14} Character set library
     1536
     1537@item @ref{Unit match, Unit match} Pattern matching runtime-support
     1538
     1539@item @ref{Unit regex, Unit regex} Regular expressions
     1540
     1541@item @ref{Unit srfi-18, Unit srfi-18} Multithreading
     1542
     1543@item @ref{Unit srfi-69, Unit srfi-69} Hash tables
    10981544
    10991545@item @ref{Unit posix, Unit posix} Unix-like services
     
    11011547@item @ref{Unit utils, Unit utils} Shell scripting and file operations
    11021548
    1103 @item @ref{Unit tcp, Unit tcp} basic TCP-sockets
    1104 
    1105 @item @ref{Unit lolevel, Unit lolevel} low-level operations
     1549@item @ref{Unit tcp, Unit tcp} Basic TCP-sockets
     1550
     1551@item @ref{Unit lolevel, Unit lolevel} Low-level operations
    11061552
    11071553
     
    11151561
    11161562
    1117 @itemize
    1118 @item Identifiers are by default case-sensitive (see @uref{http://galinha.ucpel.tche.br:8080/Using%20the%20compiler#Compiler%20command%20line%20format, Compiler command line format}).
    1119 
    1120 @item [4.1.3] The maximal number of arguments that may be passed to a compiled procedure or macro is 120.  A macro-definition that has a single rest-parameter can have any number of arguments.  If the @code{libffi} library is available on this platform, and if it is installed, then CHICKEN can take advantage of this. See the @uref{http://chicken.wiki.br/chicken/README, README} file for more details.
    1121 
    1122 @item [4.2.2] @code{letrec} does evaluate the initial values for the bound variables sequentially and not in parallel, that is:
    1123 
    1124 
    1125 @end itemize
     1563Identifiers are by default case-sensitive (see @uref{http://galinha.ucpel.tche.br:8080/Using%20the%20compiler#Compiler%20command%20line%20format, Compiler command line format}).
     1564
     1565[4.1.3] The maximal number of arguments that may be passed to a compiled procedure or macro is 120.  A macro-definition that has a single rest-parameter can have any number of arguments.  If the @code{libffi} library is available on this platform, and if it is installed, then CHICKEN can take advantage of this. See the @uref{http://chicken.wiki.br/chicken/README, README} file for more details.
     1566
     1567[4.2.2] @code{letrec} does evaluate the initial values for the bound variables sequentially and not in parallel, that is:
     1568
    11261569@verbatim
    11271570 (letrec ((x 1) (y 2)) (cons x y))
     
    11441587     (cons x y) ) )
    11451588@end verbatim
    1146 @itemize
    1147 @item [4.3] @code{syntax-rules} macros are not provided but available separately.
    1148 
    1149 @item [6.1] @code{equal?} compares all structured data recursively, while R5RS specifies that @code{eqv?} is used for data other than pairs, strings and vectors.
    1150 
    1151 @item [6.2.4]  The runtime system uses the numerical string-conversion routines of the underlying C library and so does only understand standard (C-library) syntax for floating-point constants.
    1152 
    1153 @item [6.2.5] There is no built-in support for rationals, complex numbers or extended-precision integers (bignums). The routines @code{complex?}, @code{real?} and @code{rational?} are identical to the standard procedure @code{number?}. The procedures @code{numerator}, @code{denominator}, @code{rationalize}, @code{make-rectangular} and @code{make-polar} are not implemented. Fixnums are limited to ±2<nowiki><sup>30</sup></nowiki> (or ±2<nowiki><sup>62</sup></nowiki> on 64-bit hardware).  Support for extended numbers is available as a separate package, provided the GNU multiprecision library is installed.
    1154 
    1155 @item [6.2.6] The procedure @code{string->number} does not obey read/write invariance on inexact numbers.
    1156 
    1157 @item [6.4] The maximum number of values that can be passed to continuations captured using @code{call-with-current-continuation} is 120.
    1158 
    1159 @item [6.5] Code evaluated in @code{scheme-report-environment} or @code{null-environment} still sees non-standard syntax.
    1160 
    1161 @item [6.6.2] The procedure @code{char-ready?} always returns @code{#t} for terminal ports.  The procedure @code{read} does not obey read/write invariance on inexact numbers.
    1162 
    1163 @item [6.6.3] The procedures @code{write} and @code{display} do not obey read/write invariance to inexact numbers.
    1164 
    1165 @item [6.6.4] The @code{transcript-on} and @code{transcript-off} procedures are not implemented.
    1166 
    1167 
    1168 @end itemize
     1589[4.3] @code{syntax-rules} macros are not provided but available separately.
     1590
     1591[6.1] @code{equal?} compares all structured data recursively, while R5RS specifies that @code{eqv?} is used for data other than pairs, strings and vectors.
     1592
     1593[6.2.4] The runtime system uses the numerical string-conversion routines of the underlying C library and so does only understand standard (C-library) syntax for floating-point constants.
     1594
     1595[6.2.5] There is no built-in support for rationals, complex numbers or extended-precision integers (bignums). The routines @code{complex?}, @code{real?} and @code{rational?} are identical to the standard procedure @code{number?}. The procedures @code{numerator}, @code{denominator}, @code{rationalize}, @code{make-rectangular} and @code{make-polar} are not implemented. Fixnums are limited to ±2<nowiki><sup>30</sup></nowiki> (or ±2<nowiki><sup>62</sup></nowiki> on 64-bit hardware).  Support for extended numbers is available as a separate package, provided the GNU multiprecision library is installed.
     1596
     1597[6.2.6] The procedure @code{string->number} does not obey read/write invariance on inexact numbers.
     1598
     1599[6.4] The maximum number of values that can be passed to continuations captured using @code{call-with-current-continuation} is 120.
     1600
     1601[6.5] Code evaluated in @code{scheme-report-environment} or @code{null-environment} still sees non-standard syntax.
     1602
     1603[6.6.2] The procedure @code{char-ready?} always returns @code{#t} for terminal ports.  The procedure @code{read} does not obey read/write invariance on inexact numbers.
     1604
     1605[6.6.3] The procedures @code{write} and @code{display} do not obey read/write invariance to inexact numbers.
     1606
     1607[6.6.4] The @code{transcript-on} and @code{transcript-off} procedures are not implemented.
     1608
    11691609Previous: @ref{Supported language, Supported language}
    11701610
     
    11771617[2.1] Identifiers may contain special characters if delimited with @code{| ... |}.
    11781618
    1179 [2.3] The brackets @code{[ ... ]} are provided as an alternative syntax for @code{( ... )}.  A number of reader extensions is provided. See @ref{Non-standard read syntax, Non-standard read syntax}.
     1619[2.3] The brackets @code{[ ... ]} and the braces @code{ @{ ... @} } are provided as an alternative syntax for @code{( ... )}.  A number of reader extensions is provided. See @ref{Non-standard read syntax, Non-standard read syntax}.
    11801620
    11811621[4] Numerous non-standard macros are provided. See  @ref{Non-standard macros and special forms, Non-standard macros and special forms} for more information.
    11821622
    1183 [4.1.4] Extended DSSSL style lambda lists are supported. DSSSL formal argument lists are defined by the following grammar:
    1184 
    1185 @verbatim
    1186 <formal-argument-list> ==> <required-formal-argument>*
    1187                            [(#!optional <optional-formal-argument>*)]
    1188                            [(#!rest <rest-formal-argument>)]
    1189                            [(#!key <key-formal-argument>*)]
    1190 <required-formal-argument> ==> <ident>
    1191 <optional-formal-argument> ==> <ident>
    1192                              | (<ident> <initializer>)
    1193 <rest-formal-argument> ==> <ident>
    1194 <key-formal-argument> ==> <ident>
    1195                           | (<ident> <initializer>)
     1623[4.1.4] Extended DSSSL style lambda lists are supported. DSSSL parameter lists are defined by the following grammar:
     1624
     1625@verbatim
     1626<parameter-list> ==> <required-parameter>*
     1627                     [(#!optional <optional-parameter>*)]
     1628                     [(#!rest <rest-parameter>)]
     1629                     [(#!key <keyword-parameter>*)]
     1630<required-parameter> ==> <ident>
     1631<optional-parameter> ==> <ident>
     1632                         | (<ident> <initializer>)
     1633<rest-parameter> ==> <ident>
     1634<keyword-parameter> ==> <ident>
     1635                        | (<ident> <initializer>)
    11961636<initializer> ==> <expr>
    11971637@end verbatim
    1198 When a procedure is applied to a list of actual arguments, the formal and actual arguments are processed from left to right as follows:
     1638When a procedure is applied to a list of arguments, the parameters and arguments are processed from left to right as follows:
    11991639
    12001640@itemize
    1201 @item Variables in required-formal-arguments are bound to successive actual arguments starting with the first actual argument. It shall be an error if there are fewer actual arguments than required-formal-arguments.
    1202 
    1203 @item Next, variables in optional-formal-arguments are bound to any remaining actual arguments. If there are fewer remaining actual arguments than optional-formal-arguments, then variables are bound to the result of the evaluation of initializer if one was specified or otherwise to @code{#f}. The initializer is evaluated in an environment in which all previous formal arguments have been bound.
    1204 
    1205 @item If there is a rest-formal-argument, then it is bound to a list of all remaining actual arguments. The remaining actual arguments are also eligible to be bound to keyword-formal-arguments. If there is no rest-formal-argument and there are no keywords, the it shall be an error if there are any remaining actual arguments.
    1206 
    1207 @item If @code{#!key} was specified in the formal-argument-list, there shall be an even number of remaining actual arguments. These are interpreted as a series of pairs, where the first member of each pair is a keyword specifying the argument name, and th corresponding value. It shall be an error if the first member of a pair is not a keyword. It shall be an error if the argument name is not the same as a variable in a keyword-formal-argument, unless there is a rest-formal-argument. If the same argument name occurs more than once in the list of actual arguments, then the first value is used. If there is no actual argument for a particular keyword-formal-argument, then the variable is bound to the result of evaluating initializer if one was specified or @code{#f}. The initializer is evaluated in an environment in which all previous formal arguments have been bound.
     1641@item Required-parameters are bound to successive arguments starting with the first argument. It shall be an error if there are fewer arguments than required-parameters.
     1642
     1643@item Next, the optional-parameters are bound with the remaining arguments. If there are fewer arguments than optional-parameters, then the remaining optional-parameters are bound to the result of the evaluation of their corresponding <initializer>, if one was specified, otherwise @code{#f}. The corresponding <initializer> is evaluated in an environment in which all previous parameters have been bound.
     1644
     1645@item If there is a rest-parameter, then it is bound to a list containing all the remaining arguments left over after the argument bindings with required-parameters and optional-parameters have been made.
     1646
     1647@item If @code{#!key} was specified in the parameter-list, there should be an even number of remaining arguments. These are interpreted as a series of pairs, where the first member of each pair is a keyword specifying the parameter name, and the second member is the corresponding value. If the same keyword occurs more than once in the list of arguments, then the corresponding value of the first keyword is the binding value. If there is no argument for a particular keyword-parameter, then the variable is bound to the result of evaluating <initializer>, if one was specified, otherwise @code{#f}. The corresponding <initializer> is evaluated in an environment in which all previous parameters have been bound.
    12081648
    12091649
    12101650@end itemize
    1211 It shall be an error for an @code{<ident>} to appear more than once in a formal-argument-list.
     1651Needing a special mention is the close relationship between the rest-parameter and possible keyword-parameters.  Declaring a rest-parameter binds up all remaining arguments in a list, as described above. These same remaining arguments are also used for attempted matches with declared keyword-parameters, as described above, in which case a matching keyword-parameter binds to the corresponding value argument at the same time that both the keyword and value arguments are added to the rest parameter list. Note that for efficiency reasons, the keyword-parameter matching does nothing more than simply attempt to match with pairs that may exist in the remaining arguments.  Extra arguments that don't match are simply unused and forgotten if no rest-parameter has been declared.  Because of this, the caller of a procedure containing one or more keyword-parameters cannot rely on any kind of system error to report wrong keywords being passed in.
     1652
     1653It shall be an error for an @code{<ident>} to appear more than once in a parameter-list.
     1654
     1655If there is no rest-parameter and no keyword-parameters in the parameter-list, then it shall be an error for any extra arguments to be passed to the procedure.
    12121656
    12131657Example:
     
    12831727
    12841728[6.6.1] if the procedures @code{current-input-port} and @code{current-output-port} are called with an argument (which should be a port), then that argument is selected as the new current input- and output-port, respectively.  The procedures @code{open-input-file}, @code{open-output-file}, @code{with-input-from-file}, @code{with-output-to-file}, @code{call-with-input-file} and @code{call-with-output-file} accept an optional second (or third) argument which should be one or more keywords, if supplied. These arguments specify the mode in which the file is opened. Possible values are the keywords @code{#:text}, @code{#:binary} or @code{#:append}.
     1729
     1730[6.7] The @code{exit} procedure exits a program right away and does @emph{not} invoke pending @code{dynamic-wind} thunks.
    12851731
    12861732Previous: @ref{Deviations from the standard, Deviations from the standard}
     
    13981844This is a simple string with an embedded `##' character
    13991845and substituted expressions: (+ three 99) ==> #(+ three 99)
    1400 (three is "#@{three@}")
     1846(three is "#{three}")
    14011847EOF
    14021848)
     
    15181964
    15191965@menu
    1520 * Non-standard macros and special forms - Making extra libraries and extensions availablee::
     1966* Non-standard macros and special forms - Making extra libraries and extensions available::
    15211967* Non-standard macros and special forms - Binding forms for optional arguments::
    15221968* Non-standard macros and special forms - Other binding forms::
     
    15291975
    15301976
    1531 @node Non-standard macros and special forms - Making extra libraries and extensions availablee, Non-standard macros and special forms - Binding forms for optional arguments,  , Non-standard macros and special forms
    1532 @section Making extra libraries and extensions availablee
     1977@node Non-standard macros and special forms - Making extra libraries and extensions available, Non-standard macros and special forms - Binding forms for optional arguments,  , Non-standard macros and special forms
     1978@section Making extra libraries and extensions available
    15331979
    15341980@menu
    1535 * Non-standard macros and special forms - Making extra libraries and extensions availablee - require-extension::
    1536 * Non-standard macros and special forms - Making extra libraries and extensions availablee - define-extension::
     1981* Non-standard macros and special forms - Making extra libraries and extensions available - require-extension::
     1982* Non-standard macros and special forms - Making extra libraries and extensions available - define-extension::
    15371983
    15381984@end menu
    15391985
    15401986
    1541 @node Non-standard macros and special forms - Making extra libraries and extensions availablee - require-extension, Non-standard macros and special forms - Making extra libraries and extensions availablee - define-extension,  , Non-standard macros and special forms - Making extra libraries and extensions availablee
     1987@node Non-standard macros and special forms - Making extra libraries and extensions available - require-extension, Non-standard macros and special forms - Making extra libraries and extensions available - define-extension,  , Non-standard macros and special forms - Making extra libraries and extensions available
    15421988@subsection require-extension
    15431989
     
    15471993[syntax] (use ID ...)
    15481994@end verbatim
    1549 This form does all necessary steps to make the libraries or extensions given in @code{ID ...} available. It loads syntactic extension, if needed and generates code for loading/linking with core library modules or separately installed extensions. @code{use} is just a shorter alias for @code{require-extension}. This implementation of @code{require-extension} is compliant to @uref{http://srfi.schemers.org/srfi-55/srfi-55.html, SRFI-55} (see the @uref{http://srfi.schemers.org/srfi-55/srfi-55.html, SRFI-55} document for more information).
     1995This form does all the necessary steps to make the libraries or extensions given in @code{ID ...} available. It loads syntactic extensions, if needed and generates code for loading/linking with core library modules or separately installed extensions. @code{use} is just a shorter alias for @code{require-extension}. This implementation of @code{require-extension} is compliant with @uref{http://srfi.schemers.org/srfi-55/srfi-55.html, SRFI-55} (see the @uref{http://srfi.schemers.org/srfi-55/srfi-55.html, SRFI-55} document for more information).
    15501996
    15511997During interpretation/evaluation @code{require-extension} performs one of the following:
     
    15562002@item If @code{ID} names one of the syntactic extensions @code{chicken-more-macros chicken-ffi-macros}, then this extension will be loaded.
    15572003
    1558 @item @code{ID} names one of the core library units shipped with CHICKEN, then a @code{(load-library 'ID)} will be performed.
    1559 
    1560 @item @code{ID} names an installed extension with the @code{syntax} or @code{require-at-runtime} attribute, then the equivalent of @code{(require-for-syntax 'ID)} is performed, probably followed by @code{(require ...)} for any run-time requirements.
    1561 
    1562 @item Otherwise @code{(require-extension ID)} is equivalent to @code{(require 'ID)}.
     2004@item If @code{ID} names one of the core library units shipped with CHICKEN, then a @code{(load-library 'ID)} will be performed.
     2005
     2006@item If @code{ID} names an installed extension with the @code{syntax} or @code{require-at-runtime} attribute, then the equivalent of @code{(require-for-syntax 'ID)} is performed, probably followed by @code{(require ...)} for any run-time requirements.
     2007
     2008@item Otherwise, @code{(require-extension ID)} is equivalent to @code{(require 'ID)}.
    15632009
    15642010
    15652011@end itemize
    1566 During compilation one of the following happens instead:
     2012During compilation, one of the following happens instead:
    15672013
    15682014@itemize
     
    15712017@item If @code{ID} names one of the syntactic extensions @code{chicken-more-macros chicken-ffi-macros}, then this extension will be loaded at compile-time, making the syntactic extensions available in compiled code.
    15722018
    1573 @item If @code{ID} names one of the core library units shipped with CHICKEN, or if the option @code{-uses ID} has been passed to the compiler then a @code{(declare (uses ID))} is generated.
     2019@item If @code{ID} names one of the core library units shipped with CHICKEN, or if the option @code{-uses ID} has been passed to the compiler, then a @code{(declare (uses ID))} is generated.
    15742020
    15752021@item If @code{ID} names an installed extension with the @code{syntax} or @code{require-at-runtime} attribute, then the equivalent of @code{(require-for-syntax 'ID)} is performed, and code is emitted to @code{(require ...)} any needed run-time requirements.
     
    15962042When syntax extensions are loaded that redefine the global toplevel macro-expander (for example the @uref{http://www.call-with-current-continuation.org/eggs/syntax-case.html, syntax-case} extension), then all remaining expression @emph{in the same toplevel form} are still expanded with the old toplevel macro-expander.
    15972043
    1598 @node Non-standard macros and special forms - Making extra libraries and extensions availablee - define-extension,  , Non-standard macros and special forms - Making extra libraries and extensions availablee - require-extension, Non-standard macros and special forms - Making extra libraries and extensions availablee
     2044@node Non-standard macros and special forms - Making extra libraries and extensions available - define-extension,  , Non-standard macros and special forms - Making extra libraries and extensions available - require-extension, Non-standard macros and special forms - Making extra libraries and extensions available
    15992045@subsection define-extension
    16002046
     
    16052051This macro simplifies the task of writing extensions that can be linked both statically and dynamically. If encountered in interpreted code or code that is compiled into a shared object (specifically if compiled with the feature @code{chicken-compile-shared}, done automatically by @code{csc} when compiling with the @code{-shared} or @code{-dynamic} option) then the code given by clauses of the form
    16062052
    1607 <enscript highlight=scheme> (dynamic EXPRESSION ...) </enscript>
    1608 
     2053@example
     2054(dynamic EXPRESSION ...)
     2055@end example
    16092056are inserted into the output as a @code{begin} form.
    16102057
    16112058If compiled statically (specifically if the feature @code{chicken-compile-shared} has not been given), then this form expands into the following:
    16122059
    1613 <enscript highlight=scheme> (declare (unit NAME)) (provide 'NAME) </enscript>
    1614 
     2060@example
     2061(declare (unit NAME))
     2062(provide 'NAME)
     2063@end example
    16152064and all clauses of the form
    16162065
    1617 <enscript highlight=scheme> (static EXPRESSION ...) </enscript>
    1618 
     2066@example
     2067(static EXPRESSION ...)
     2068@end example
    16192069all additionally inserted into the expansion.
    16202070
    16212071As a convenience, the clause
    16222072
    1623 <enscript highlight=scheme> (export IDENTIFIER ...) </enscript>
    1624 
     2073@example
     2074(export IDENTIFIER ...)
     2075@end example
    16252076is also allowed and is identical to @code{(declare (export IDENTIFIER ...))} (unless the @code{define-extension} form occurs in interpreted code, in with it is simply ignored).
    16262077
    16272078Note that the compiler option @code{-extension NAME} is equivalent to prefixing the compiled file with
    16282079
    1629 <enscript highlight=scheme> (define-extension NAME) </enscript>
    1630 
    1631 @node Non-standard macros and special forms - Binding forms for optional arguments, Non-standard macros and special forms - Other binding forms, Non-standard macros and special forms - Making extra libraries and extensions availablee, Non-standard macros and special forms
     2080@example
     2081(define-extension NAME)
     2082@end example
     2083@node Non-standard macros and special forms - Binding forms for optional arguments, Non-standard macros and special forms - Other binding forms, Non-standard macros and special forms - Making extra libraries and extensions available, Non-standard macros and special forms
    16322084@section Binding forms for optional arguments
    16332085
     
    16502102Use this form for procedures that take a single optional argument. If @code{ARGS} is the empty list @code{DEFAULT} is evaluated and returned, otherwise the first element of the list @code{ARGS}. It is an error if @code{ARGS} contains more than one value.
    16512103
    1652 <enscript highlight=scheme> (define (incr x . i) (+ x (optional i 1))) (incr 10)                                   ==> 11 (incr 12 5)                                 ==> 17 </enscript>
    1653 
     2104@example
     2105(@strong{define} (@strong{incr} x . i) (+ x (optional i 1)))
     2106(incr 10)                                   =@strong{=>} 11
     2107(incr 12 5)                                 =@strong{=>} 17
     2108@end example
    16542109@node Non-standard macros and special forms - Binding forms for optional arguments - case-lambda, Non-standard macros and special forms - Binding forms for optional arguments - let-optionals, Non-standard macros and special forms - Binding forms for optional arguments - optional, Non-standard macros and special forms - Binding forms for optional arguments
    16552110@subsection case-lambda
     
    16612116Expands into a lambda that invokes the body following the first matching lambda-list.
    16622117
    1663 <enscript highlight=scheme> (define plus
    1664 
    1665 @verbatim
    1666  (case-lambda
    1667    (() 0)
    1668    ((x) x)
    1669    ((x y) (+ x y))
    1670    ((x y z) (+ (+ x y) z))
    1671    (args (apply + args))))
    1672 @end verbatim
    1673 (plus)                      ==> 9 (plus 1)                    ==> 1 (plus 1 2 3)                ==> 6 </enscript>
    1674 
     2118@example
     2119(@strong{define} @strong{plus}
     2120  (case-lambda
     2121    (() 0)
     2122    ((x) x)
     2123    ((x y) (+ x y))
     2124    ((x y z) (+ (+ x y) z))
     2125    (args (apply + args))))
     2126
     2127(plus)                      =@strong{=>} 9
     2128(plus 1)                    =@strong{=>} 1
     2129(plus 1 2 3)                =@strong{=>} 6
     2130@end example
    16752131For more information see the documentation for @uref{http://srfi.schemers.org/srfi-16/srfi-16.html, SRFI-16}
    16762132
     
    16842140Binding constructs for optional procedure arguments. @code{ARGS} should be a rest-parameter taken from a lambda-list. @code{let-optionals} binds @code{VAR1 ...} to available arguments in parallel, or to @code{DEFAULT1 ...} if not enough arguments were provided. @code{let-optionals*} binds @code{VAR1 ...} sequentially, so every variable sees the previous ones. it is an error if any excess arguments are provided.
    16852141
    1686 <enscript highlight=scheme> (let-optionals '(one two) ((a 1) (b 2) (c 3))
    1687 
    1688 @verbatim
    1689  (list a b c) )                               ==> (one two 3)
    1690 @end verbatim
    1691 </enscript>
    1692 
     2142@example
     2143(let-optionals '(one two) ((a 1) (b 2) (c 3))
     2144  (list a b c) )                               =@strong{=>} (one two 3)
     2145@end example
    16932146@node Non-standard macros and special forms - Binding forms for optional arguments - let-optionals*,  , Non-standard macros and special forms - Binding forms for optional arguments - let-optionals, Non-standard macros and special forms - Binding forms for optional arguments
    16942147@subsection let-optionals*
     
    17002153Binding constructs for optional procedure arguments. @code{ARGS} should be a rest-parameter taken from a lambda-list. @code{let-optionals} binds @code{VAR1 ...} to available arguments in parallel, or to @code{DEFAULT1 ...} if not enough arguments were provided. @code{let-optionals*} binds @code{VAR1 ...} sequentially, so every variable sees the previous ones. If a single variable @code{RESTVAR} is given, then it is bound to any remaining arguments, otherwise it is an error if any excess arguments are provided.
    17012154
    1702 <enscript highlight=scheme> (let-optionals* '(one two) ((a 1) (b 2) (c a))
    1703 
    1704 @verbatim
    1705  (list a b c) )                               ==> (one two one)
    1706 @end verbatim
    1707 </enscript>
    1708 
     2155@example
     2156(let-optionals* '(one two) ((a 1) (b 2) (c a))
     2157  (list a b c) )                               =@strong{=>} (one two one)
     2158@end example
    17092159@node Non-standard macros and special forms - Other binding forms, Non-standard macros and special forms - Substitution forms and macros, Non-standard macros and special forms - Binding forms for optional arguments, Non-standard macros and special forms
    17102160@section Other binding forms
     
    17912241Binds multiple variables to the result values of @code{EXP ...}. The variables are bound sequentially.
    17922242
    1793 <enscript highlight=scheme> (let*-values (((a b) (values 2 3))
    1794 
    1795 @verbatim
    1796              ((p) (+ a b)) )
    1797  p)                               ==> 5
    1798 @end verbatim
    1799 </enscript>
    1800 
     2243@example
     2244(let*-values (((a b) (values 2 3))
     2245              ((p) (+ a b)) )
     2246  p)                               =@strong{=>} 5
     2247@end example
    18012248@node Non-standard macros and special forms - Other binding forms - letrec-values, Non-standard macros and special forms - Other binding forms - parameterize, Non-standard macros and special forms - Other binding forms - let*-values, Non-standard macros and special forms - Other binding forms
    18022249@subsection letrec-values
     
    18082255Binds the result values of @code{EXP ...} to multiple variables at once. All variables are mutually recursive.
    18092256
    1810 <enscript highlight=scheme> (letrec-values (((odd even)
    1811 
    1812 @verbatim
    1813                   (values
    1814                     (lambda (n) (if (zero? n) #f (even (sub1 n))))
    1815                     (lambda (n) (if (zero? n) #t (odd (sub1 n)))) ) ) )
    1816  (odd 17) )                           ==> #t
    1817 @end verbatim
    1818 </enscript>
    1819 
     2257@example
     2258(letrec-values (((odd even)
     2259                   (values
     2260                     (@strong{lambda} (n) (@strong{if} (zero? n) #f (even (sub1 n))))
     2261                     (@strong{lambda} (n) (@strong{if} (zero? n) #t (odd (sub1 n)))) ) ) )
     2262  (odd 17) )                           =@strong{=>} #t
     2263@end example
    18202264@node Non-standard macros and special forms - Other binding forms - parameterize, Non-standard macros and special forms - Other binding forms - receive, Non-standard macros and special forms - Other binding forms - letrec-values, Non-standard macros and special forms - Other binding forms
    18212265@subsection parameterize
     
    18392283The syntax
    18402284
    1841 <enscript highlight=scheme> (receive VALUEEXP) </enscript>
    1842 
     2285@example
     2286(receive VALUEEXP)
     2287@end example
    18432288is equivalent to
    18442289
    1845 <enscript highlight=scheme> (receive _ VALUEEXP _) </enscript>
    1846 
     2290@example
     2291(receive _ VALUEEXP _)
     2292@end example
    18472293@node Non-standard macros and special forms - Other binding forms - set!-values,  , Non-standard macros and special forms - Other binding forms - receive, Non-standard macros and special forms - Other binding forms
    18482294@subsection set!-values
     
    19372383Equivalent to:
    19382384
    1939 <enscript highlight=scheme> (if (not TEST) (begin EXP1 EXP2 ...)) </enscript>
    1940 
     2385@example
     2386(@strong{if} (not TEST) (@strong{begin} EXP1 EXP2 ...))
     2387@end example
    19412388@node Non-standard macros and special forms - Conditional forms - when,  , Non-standard macros and special forms - Conditional forms - unless, Non-standard macros and special forms - Conditional forms
    19422389@subsection when
     
    19482395Equivalent to:
    19492396
    1950 <enscript highlight=scheme> (if TEST (begin EXP1 EXP2 ...)) </enscript>
    1951 
     2397@example
     2398(@strong{if} TEST (@strong{begin} EXP1 EXP2 ...))
     2399@end example
    19522400@node Non-standard macros and special forms - Record structures, Non-standard macros and special forms - Other forms, Non-standard macros and special forms - Conditional forms, Non-standard macros and special forms
    19532401@section Record structures
     
    19702418Defines a record type. Call @code{make-NAME} to create an instance of the structure (with one initialization-argument for each slot). @code{(NAME? STRUCT)} tests any object for being an instance of this structure.  Slots are accessed via @code{(NAME-SLOTNAME STRUCT)} and updated using @code{(NAME-SLOTNAME-set!} @code{STRUCT} @code{VALUE)}.
    19712419
    1972 <enscript highlight=scheme> (define-record point x y) (define p1 (make-point 123 456)) (point? p1)                      ==> #t (point-x p1)                     ==> 123 (point-y-set! p1 99) (point-y p1)                     ==> 99 </enscript>
    1973 
     2420@example
     2421(define-record point x y)
     2422(@strong{define} @strong{p1} (make-point 123 456))
     2423(point? p1)                      =@strong{=>} #t
     2424(point-x p1)                     =@strong{=>} 123
     2425(point-y-set! p1 99)
     2426(point-y p1)                     =@strong{=>} 99
     2427@end example
    19742428@node Non-standard macros and special forms - Record structures - define-record-printer, Non-standard macros and special forms - Record structures - define-record-type, Non-standard macros and special forms - Record structures - define-record, Non-standard macros and special forms - Record structures
    19752429@subsection define-record-printer
     
    19822436Defines a printing method for record of the type @code{NAME} by associating a procedure with the record type. When a record of this type is written using @code{display, write} or @code{print}, then the procedure is called with two arguments: the record to be printed and an output-port.
    19832437
    1984 <enscript highlight=scheme> (define-record foo x y z) (define f (make-foo 1 2 3)) (define-record-printer (foo x out)
    1985 
    1986 @verbatim
    1987  (fprintf out "#,(foo ~S ~S ~S)"
    1988           (foo-x x) (foo-y x) (foo-z x)) )
    1989 @end verbatim
    1990 (define-reader-ctor 'foo make-foo) (define s (with-output-to-string
    1991 
    1992 @verbatim
    1993              (lambda () (write f))))
    1994 @end verbatim
    1995 s                                   ==> "#,(foo 1 2 3)" (equal? f (with-input-from-string
    1996 
    1997 @verbatim
    1998              s read)))             ==> #t
    1999 @end verbatim
    2000 </enscript>
    2001 
     2438@example
     2439(define-record foo x y z)
     2440(@strong{define} @strong{f} (make-foo 1 2 3))
     2441(define-record-printer (foo x out)
     2442  (fprintf out @strong{"#,(foo ~S ~S ~S)"}
     2443           (foo-x x) (foo-y x) (foo-z x)) )
     2444(define-reader-ctor 'foo make-foo)
     2445(@strong{define} @strong{s} (with-output-to-string
     2446              (@strong{lambda} () (write f))))
     2447s                                   =@strong{=>} @strong{"#,(foo 1 2 3)"}
     2448(equal? f (with-input-from-string
     2449              s read)))             =@strong{=>} #t
     2450@end example
    20022451@code{define-record-printer} works also with SRFI-9 record types.
    20032452
     
    20632512The following feature-identifiers are available in all situations: @code{(machine-byte-order)}, @code{(machine-type)}, @code{(software-type)}, @code{(software-version)}, where the actual feature-identifier is platform dependent.
    20642513
    2065 In addition the following feature-identifiers may exist: @code{applyhook}, @code{extraslot}, @code{ptables}, @code{dload}, @code{libffi}.
     2514In addition the following feature-identifiers may exist: @code{applyhook}, @code{extraslot}, @code{ptables}, @code{dload}.
    20662515
    20672516For further information, see the documentation for @uref{http://srfi.schemers.org/srfi-0/srfi-0.html, SRFI-0}.
     
    21392588Pattern matching allows complicated control decisions based on data structure to be expressed in a concise manner.  Pattern matching is found in several modern languages, notably Standard ML, Haskell and Miranda. These syntactic extensions internally use the @code{match} library unit.
    21402589
     2590Note: this pattern matching package is not compatible with hygienic macro-expanders like the @code{syntax-case} extension (available separately).
     2591
    21412592The basic form of pattern matching expression is:
    21422593
    2143 <enscript highlight=scheme> (match exp [pat body] ...) </enscript>
    2144 
     2594@example
     2595(match exp [pat body] ...)
     2596@end example
    21452597where @code{exp} is an expression, @code{pat} is a pattern, and @code{body} is one or more expressions (like the body of a lambda-expression). The @code{match} form matches its first subexpression against a sequence of patterns, and branches to the @code{body} corresponding to the first pattern successfully matched. For example, the following code defines the usual @code{map} function:
    21462598
    2147 <enscript highlight=scheme> (define map
    2148 
    2149 @verbatim
    2150  (lambda (f l)
    2151    (match l
    2152      [() '()]
    2153      [(x . y) (cons (f x) (map f y))])))
    2154 @end verbatim
    2155 </enscript>
    2156 
     2599@example
     2600(@strong{define} @strong{map}
     2601  (@strong{lambda} (f l)
     2602    (match l
     2603      [() '()]
     2604      [(x . y) (cons (f x) (map f y))])))
     2605@end example
    21572606The first pattern @code{()} matches the empty list.  The second pattern @code{(x . y)} matches a pair, binding @code{x} to the first component of the pair and @code{y} to the second component of the pair.
    21582607
     
    22272676                             a vector of n+k or more elements
    22282677    |  ,pat                  a pattern
    2229     |  ,@@pat                 a pattern, spliced
     2678    |  ,@pat                 a pattern, spliced
    22302679@end verbatim
    22312680The notation @code{..k} denotes a keyword consisting of three consecutive dots (ie., @emph{@code{...}}),  or two dots and an non-negative integer (eg., @emph{@code{..1}}, @emph{@code{..2}}), or three consecutive underscores (ie., @emph{@code{___}}), or two underscores and a non-negative integer. The keywords @emph{@code{..k}} and @emph{@code{__ k}} are equivalent. The keywords @emph{@code{...}}, @emph{@code{___}}, @emph{@code{..0}}, and @emph{@code{__0}} are equivalent.
     
    22352684The @code{match-lambda} and @code{match-lambda*} forms are convenient combinations of @code{match} and @code{lambda}, and can be explained as follows:
    22362685
    2237 <enscript highlight=scheme> (match-lambda [pat body] ...)   =  (lambda (x) (match x [pat body] ...)) (match-lambda* [pat body] ...)  =  (lambda x (match x [pat body] ...)) </enscript>
    2238 
     2686@example
     2687(match-lambda [pat body] ...)   =  (@strong{lambda} (x) (match x [pat body] ...))
     2688(match-lambda* [pat body] ...)  =  (@strong{lambda} x (match x [pat body] ...))
     2689@end example
    22392690where @code{x} is a unique variable. The @code{match-lambda} form is convenient when defining a single argument function that immediately destructures its argument. The @code{match-lambda*} form constructs a function that accepts any number of arguments; the patterns of @code{match-lambda*} should be lists.
    22402691
    22412692The @code{match-let}, @code{match-let*}, @code{match-letrec}, and @code{match-define} forms generalize Scheme's @code{let}, @code{let*}, @code{letrec}, and @code{define} expressions to allow patterns in the binding position rather than just variables. For example, the following expression:
    22422693
    2243 <enscript highlight=scheme> (match-let ([(x y z) (list 1 2 3)]) body ...) </enscript>
    2244 
     2694@example
     2695(match-let ([(x y z) (list 1 2 3)]) body ...)
     2696@end example
    22452697binds @code{x} to 1, @code{y} to 2, and @code{z} to 3 in @code{body ...}. These forms are convenient for destructuring the result of a function that returns multiple values as a list or vector. As usual for @code{letrec} and @code{define}, pattern variables bound by @code{match-letrec} and @code{match-define} should not be used in computing the bound value.
    22462698
     
    22632715@code{(pat-1 ... pat-n pat-n+1 ...)}: matches a proper list of @code{n} or more elements, where each element of the tail matches @code{pat-n+1}.  Each pattern variable in @code{pat-n+1} is bound to a list of the matching values.  For example, the expression:
    22642716
    2265 <enscript highlight=scheme> (match '(let ([x 1][y 2]) z)
    2266 
    2267 @verbatim
    2268  [('let ((binding values) ...) exp)  body])
    2269 @end verbatim
    2270 </enscript>
    2271 
     2717@example
     2718(match '(@strong{let} ([x 1][y 2]) z)
     2719  [('@strong{let} ((binding values) ...) exp)  body])
     2720@end example
    22722721binds @code{binding} to the list @code{'(x y)}, @code{values} to the list \@code{'(1 2)}, and @code{exp} to @code{'z} in the body of the @code{match}-expression. For the special case where @code{pat-n+1} is a pattern variable, the list bound to that variable may share with the matched value.
    22732722
     
    22982747@code{(set! identifier)}: matches anything, and binds @code{identifier} to a procedure of one argument that mutates the corresponding field of the matching value. This pattern must be nested within a pair, vector, box, or structure pattern. For example, the expression:
    22992748
    2300 <enscript highlight=scheme> (define x (list 1 (list 2 3))) (match x [(_ (_ (set! setit)))  (setit 4)]) </enscript>
    2301 
     2749@example
     2750(@strong{define} @strong{x} (list 1 (list 2 3)))
     2751(match x [(_ (_ (@strong{set!} setit)))  (setit 4)])
     2752@end example
    23022753mutates the @code{cadadr} of @code{x} to 4, so that @code{x} is @code{'(1 (2 4))}.
    23032754
     
    23122763If no clause matches the value, the default action  is to invoke the procedure @code{(match-error-procedure)} with the value that did not match.  The default definition of @code{(match-error-procedure)} calls @code{error} with an appropriate message:
    23132764
    2314 <enscript highlight=scheme>
    2315 
    2316 @enumerate
    2317 @item ;1> (match 1 (2 2))
    2318 
    2319 
    2320 @end enumerate
    2321 Failed match: Error: no matching clause for : 1 </enscript>
    2322 
     2765@example
     2766#@emph{;1> (match 1 (2 2))
     2767}
     2768Failed match:
     2769Error: no matching clause for @strong{:} 1
     2770@end example
    23232771For most situations, this behavior is adequate, but it can be changed by altering the value of the parameter @code{match-error-control}:
    23242772
     
    23292777
    23302778@end table
    2331 <enscript highlight=scheme> (match-error-control [MODE]) </enscript> Selects a mode that specifies how @code{match...} macro forms are to be expanded.  With no argument this procedure returns the current mode. A single argument specifies the new mode that decides what should happen if no match-clause applies.  The following modes are supported:
     2779@example
     2780(match-error-control [MODE])
     2781@end example
     2782Selects a mode that specifies how @code{match...} macro forms are to be expanded.  With no argument this procedure returns the current mode. A single argument specifies the new mode that decides what should happen if no match-clause applies.  The following modes are supported:
    23322783
    23332784<table>
     
    23672818
    23682819@end table
    2369 <enscript highlight=scheme> (match-error-procedure [PROCEDURE]) </enscript> Sets or returns the procedure called upon a match error. The procedure takes one argument, the value which failed to match. When the error control mode is @code{#:match} a second argument, the source form of the match expression is available.
     2820@example
     2821(match-error-procedure [PROCEDURE])
     2822@end example
     2823Sets or returns the procedure called upon a match error. The procedure takes one argument, the value which failed to match. When the error control mode is @code{#:match} a second argument, the source form of the match expression is available.
    23702824
    23712825@node Pattern matching - Record Structures Pattern, Pattern matching - Code Generation, Pattern matching - Match Failure, Pattern matching
     
    23812835Pattern matching macros are compiled into @code{if}-expressions that decompose the value being matched with standard Scheme procedures, and test the components with standard predicates. Rebinding or lexically shadowing the names of any of these procedures will change the semantics of the @code{match} macros.  The names that should not be rebound or shadowed are:
    23822836
    2383 <enscript highlight=scheme> null? pair? number? string? symbol? boolean? char? procedure? vector? list? equal? car cdr cadr cdddr ... vector-length vector-ref reverse length call/cc </enscript>
    2384 
     2837@example
     2838null? pair? number? string? symbol? boolean? char? procedure? vector? list?
     2839equal?
     2840car cdr cadr cdddr ...
     2841vector-length vector-ref
     2842reverse length call/cc
     2843@end example
    23852844Additionally, the code generated to match a structure pattern like @code{($ Foo pat-1 ... pat-n)} refers to the name @code{Foo?}. This name also should not be shadowed.
    23862845
     
    24012860* Declarations - c-options::
    24022861* Declarations - check-c-syntax::
    2403 * Declarations - compress-literals::
    24042862* Declarations - constant::
    24052863* Declarations - export::
     
    24922950Declares additional C/C++ compiler options that are to be passed to the subsequent compilation pass that translates C to machine code. This declaration will only work if the source file is compiled with the @code{csc} compiler driver.
    24932951
    2494 @node Declarations - check-c-syntax, Declarations - compress-literals, Declarations - c-options, Declarations
     2952@node Declarations - check-c-syntax, Declarations - constant, Declarations - c-options, Declarations
    24952953@section check-c-syntax
    24962954
     
    25022960Enables or disables syntax-checking of embedded C/C++ code fragments. Checking C syntax is the default.
    25032961
    2504 @node Declarations - compress-literals, Declarations - constant, Declarations - check-c-syntax, Declarations
    2505 @section compress-literals
    2506 
    2507 
    2508 @verbatim
    2509 [declaration specifier] (compress-literals [THRESHOLD [INITIALIZER]])
    2510 @end verbatim
    2511 The same as the @code{-compress-literals} compiler option. The threshold argument defaults to 50. If the optional argument @code{INITIALIZER} is given, then the literals will not be created at module startup, but when the procedure with this name will be called.
    2512 
    2513 @node Declarations - constant, Declarations - export, Declarations - compress-literals, Declarations
     2962@node Declarations - constant, Declarations - export, Declarations - check-c-syntax, Declarations
    25142963@section constant
    25152964
     
    27893238Certain behavior of the interpreter and compiled programs can be customized via 'parameters', where a parameter is a procedure of zero or one arguments. To retrieve the value of a parameter call the parameter-procedure with zero arguments. To change the setting of the parameter, call the parameter-procedure with the new value as argument:
    27903239
    2791 <enscript highlight=scheme> (define foo (make-parameter 123)) (foo)                             ==> 123 (foo 99) (foo)                             ==> 99 </enscript>
    2792 
     3240@example
     3241(@strong{define} @strong{foo} (make-parameter 123))
     3242(foo)                             =@strong{=>} 123
     3243(foo 99)
     3244(foo)                             =@strong{=>} 99
     3245@end example
    27933246Parameters are fully thread-local, each thread of execution owns a local copy of a parameters' value.
    27943247
     
    29063359* Unit library - Standard Input/Output::
    29073360* Unit library - User-defined named characters::
     3361* Unit library - Blobs::
    29083362* Unit library - Vectors::
    29093363* Unit library - The unspecified value::
     
    29113365* Unit library - Setters::
    29123366* Unit library - Reader extensions::
     3367* Unit library - Property lists::
    29133368
    29143369@end menu
     
    29293384* Unit library - Arithmetic - signum::
    29303385* Unit library - Arithmetic - finite?::
     3386* Unit library - Arithmetic - flonum-print-precision::
    29313387
    29323388@end menu
     
    29523408
    29533409
    2954 Binary integer operations. @code{arithmetic-shift} shifts the argument @code{N1} by @code{N2} bits to the left. If @code{N2} is negative, than @code{N1} is shifted to the right.  These operations only accept exact integers or inexact integers in word range (32 bit signed on 32-bit platforms, or 64 bit signed on 64-bit platforms).
     3410Binary integer operations. @code{arithmetic-shift} shifts the argument @code{N1} by @code{N2} bits to the left. If @code{N2} is negative, than @code{N1} is shifted to the right. These operations only accept exact integers or inexact integers in word range (32 bit signed on 32-bit platforms, or 64 bit signed on 64-bit platforms).
    29553411
    29563412@table @b
     
    30643520
    30653521
    3066 In safe mode, these procedures throw a type error with non-float arguments (except @code{flonum?}, which returns @code{#f}).  In unsafe mode, these procedures do not check their arguments. A non-flonum argument in unsafe mode can crash the system.
     3522In safe mode, these procedures throw a type error with non-float arguments (except @code{flonum?}, which returns @code{#f}). In unsafe mode, these procedures do not check their arguments. A non-flonum argument in unsafe mode can crash the system.
    30673523
    30683524@table @b
     
    31153571[procedure] (signum N)
    31163572@end verbatim
    3117 Returns @code{1} if @code{N} is positive, @code{-1} if @code{N}  is negative or @code{0} if @code{N} is zero. @code{signum} is exactness preserving.
    3118 
    3119 @node Unit library - Arithmetic - finite?,  , Unit library - Arithmetic - signum, Unit library - Arithmetic
     3573Returns @code{1} if @code{N} is positive, @code{-1} if @code{N} is negative or @code{0} if @code{N} is zero. @code{signum} is exactness preserving.
     3574
     3575@node Unit library - Arithmetic - finite?, Unit library - Arithmetic - flonum-print-precision, Unit library - Arithmetic - signum, Unit library - Arithmetic
    31203576@subsection finite?
    31213577
     
    31253581@end verbatim
    31263582Returns @code{#f} if @code{N} is negative or positive infinity, and @code{#t} otherwise.
     3583
     3584@node Unit library - Arithmetic - flonum-print-precision,  , Unit library - Arithmetic - finite?, Unit library - Arithmetic
     3585@subsection flonum-print-precision
     3586
     3587
     3588@verbatim
     3589[procedure] (flonum-print-precision [PRECISION])
     3590@end verbatim
     3591Returns the existing number of digits after the decimal place used in printing a @code{flonum}.
     3592
     3593The optional @code{non-negative-fixnum} @code{PRECISION} sets the current print precision.
    31273594
    31283595@node Unit library - File Input/Output, Unit library - Files, Unit library - Arithmetic, Unit library
     
    31473614[procedure] (current-output-port [PORT])
    31483615@end verbatim
    3149 Returns default output port.  If @code{PORT} is given, then that port is selected as the new current output port.
    3150 
    3151 Note that the default output port is not buffered. Use @ref{Unit posix - Setting the file buffering mode, @code{set-buffering-mode!}} if you need a different behaviour.
     3616Returns default output port. If @code{PORT} is given, then that port is selected as the new current output port.
     3617
     3618Note that the default output port is not buffered. Use [[Unit posix#Setting the file buffering mode|@code{set-buffering-mode!}]] if you need a different behavior.
    31523619
    31533620@node Unit library - File Input/Output - current-error-port, Unit library - File Input/Output - flush-output, Unit library - File Input/Output - current-output-port, Unit library - File Input/Output
     
    31603627Returns default error output port. If @code{PORT} is given, then that port is selected as the new current error output port.
    31613628
    3162 Note that the default error output port is not buffered. Use @ref{Unit posix - Setting the file buffering mode, @code{set-buffering-mode!}} if you need a different behaviour.
     3629Note that the default error output port is not buffered. Use [[Unit posix#Setting the file buffering mode|@code{set-buffering-mode!}]] if you need a different behavior.
    31633630
    31643631@node Unit library - File Input/Output - flush-output, Unit library - File Input/Output - port-name, Unit library - File Input/Output - current-error-port, Unit library - File Input/Output
     
    31783645[procedure] (port-name [PORT])
    31793646@end verbatim
    3180 Fetch filename from @code{PORT}. This returns the filename that was used to open this file.  Returns a special tag string, enclosed into parentheses for non-file ports. @code{PORT} defaults to the value of @code{(current-input-port)}.
     3647Fetch filename from @code{PORT}. This returns the filename that was used to open this file. Returns a special tag string, enclosed into parentheses for non-file ports. @code{PORT} defaults to the value of @code{(current-input-port)}.
    31813648
    31823649@node Unit library - File Input/Output - port-position, Unit library - File Input/Output - set-port-name!, Unit library - File Input/Output - port-name, Unit library - File Input/Output
     
    32863753
    32873754
    3288 CHICKEN maintains a global list of @emph{features} naming functionality available int the current system. Additionally the @code{cond-expand} form accesses this feature list to infer what features are provided. Predefined features are @code{chicken}, and the SRFIs (Scheme Request For Implementation) provided by the base system: @code{srfi-23, srfi-30, srfi-39}. If the @code{eval} unit is used (the default), the features @code{srfi-0, srfi-2, srfi-6, srfi-8, srfi-9} and @code{srfi-10} are defined. When compiling code (during compile-time) the feature @code{compiling} is registered. When evaluating code in the interpreter (csi), the feature @code{csi} is registered.
     3755CHICKEN maintains a global list of @emph{features} naming functionality available in the current system. Additionally the @code{cond-expand} form accesses this feature list to infer what features are provided. Predefined features are @code{chicken}, and the SRFIs (Scheme Request For Implementation) provided by the base system: @code{srfi-23, srfi-30, srfi-39}. If the @code{eval} unit is used (the default), the features @code{srfi-0, srfi-2, srfi-6, srfi-8, srfi-9} and @code{srfi-10} are defined. When compiling code (during compile-time) the feature @code{compiling} is registered. When evaluating code in the interpreter (csi), the feature @code{csi} is registered.
    32893756
    32903757@node Unit library - Feature identifiers - features, Unit library - Feature identifiers - feature?,  , Unit library - Feature identifiers
     
    33363803
    33373804
    3338 Keywords are special symbols prefixed with @code{#:} that evaluate to themselves.  Procedures can use keywords to accept optional named parameters in addition to normal required parameters. Assignment to and bindings of keyword symbols is not allowed. The parameter @code{keyword-style} and the compiler/interpreter option @code{-keyword-style} can be used to allow an additional keyword syntax, either compatible to Common LISP, or to DSSSL.
     3805Keywords are special symbols prefixed with @code{#:} that evaluate to themselves. Procedures can use keywords to accept optional named parameters in addition to normal required parameters. Assignment to and bindings of keyword symbols is not allowed. The parameter @code{keyword-style} and the compiler/interpreter option @code{-keyword-style} can be used to allow an additional keyword syntax, either compatible to Common LISP, or to DSSSL.
    33393806
    33403807@node Unit library - Keywords - get-keyword, Unit library - Keywords - keyword?,  , Unit library - Keywords
     
    33453812[procedure] (get-keyword KEYWORD ARGLIST [THUNK])
    33463813@end verbatim
    3347 Returns the argument from @code{ARGLIST} specified under the keyword @code{KEYWORD}.  If the keyword is not found, then the zero-argument procedure @code{THUNK} is invoked and the result value is returned. If @code{THUNK} is not given, @code{#f} is returned.
    3348 
    3349 <enscript highlight=scheme> (define (increase x . args)
    3350 
    3351 @verbatim
    3352  (+ x (get-keyword #:amount args (lambda () 1))) )
    3353 @end verbatim
    3354 (increase 123)                                      ==> 124 (increase 123 #:amount 10)                          ==> 133 </enscript>
    3355 
     3814Returns the argument from @code{ARGLIST} specified under the keyword @code{KEYWORD}. If the keyword is not found, then the zero-argument procedure @code{THUNK} is invoked and the result value is returned. If @code{THUNK} is not given, @code{#f} is returned.
     3815
     3816@example
     3817(@strong{define} (@strong{increase} x . args)
     3818  (+ x (get-keyword #:amount args (@strong{lambda} () 1))) )
     3819(increase 123)                                      =@strong{=>} 124
     3820(increase 123 #:amount 10)                          =@strong{=>} 133
     3821@end example
    33563822Note: the @code{KEYWORD} may actually be any kind of object.
    33573823
     
    34043870Evaluates @code{EXPRESSION} and handles any exceptions that are covered by @code{CLAUSE ...}, where @code{CLAUSE} should be of the following form:
    34053871
    3406 <enscript highlight=scheme> CLAUSE = ([VARIABLE] (KIND ...) BODY ...) </enscript>
    3407 
    3408 If provided, @code{VARIABLE} will be bound to the signalled exception object. @code{BODY ...} is executed when the exception is a property- or composite condition with the kinds given @code{KIND ...} (unevaluated). If no clause applies, the exception is re-signalled in the same dynamic context as the @code{condition-case} form.
    3409 
    3410 <enscript highlight=scheme> (define (check thunk)
    3411 
    3412 @verbatim
    3413  (condition-case (thunk)
    3414    [(exn file) (print "file error")]
    3415    [(exn) (print "other error")]
    3416    [var () (print "something else")] ) )
    3417 @end verbatim
    3418 (check (lambda () (open-input-file "")))   ; -> "file error" (check (lambda () some-unbound-variable))  ; -> "othererror" (check (lambda () (signal 99)))            ; -> "something else"
    3419 
     3872@example
     3873CLAUSE = ([VARIABLE] (KIND ...) BODY ...)
     3874@end example
     3875If provided, @code{VARIABLE} will be bound to the signaled exception object. @code{BODY ...} is executed when the exception is a property- or composite condition with the kinds given @code{KIND ...} (unevaluated). If no clause applies, the exception is re-signaled in the same dynamic context as the @code{condition-case} form.
     3876
     3877@example
     3878(@strong{define} (@strong{check} thunk)
     3879  (condition-case (thunk)
     3880    [(exn file) (print @strong{"file error"})]
     3881    [(exn) (print @strong{"other error"})]
     3882    [var () (print @strong{"something else"})] ) )
     3883
     3884(check (@strong{lambda} () (open-input-file @strong{""})))   @emph{; -> "file error"
     3885}(check (@strong{lambda} () some-unbound-variable))  @emph{; -> "othererror"
     3886}(check (@strong{lambda} () (signal 99)))            @emph{; -> "something else"
     3887}
    34203888(condition-case some-unbound-variable
    3421 
    3422 @verbatim
    3423  [(exn file) (print "ignored")] )      ; -> signals error
    3424 @end verbatim
    3425 </enscript>
    3426 
     3889  [(exn file) (print @strong{"ignored"})] )      @emph{; -> signals error
     3890}
     3891@end example
    34273892@node Unit library - Exceptions - breakpoint,  , Unit library - Exceptions - condition-case, Unit library - Exceptions
    34283893@subsection breakpoint
     
    34343899Programmatically triggers a breakpoint (similar to the @code{,br} top-level csi command).
    34353900
    3436 All error-conditions signalled by the system are of kind @code{exn}. The following composite conditions are additionally defined:
     3901All error-conditions signaled by the system are of kind @code{exn}. The following composite conditions are additionally defined:
    34373902
    34383903<table>
     
    34403905<tr><td> (exn arity)
    34413906
    3442 Signalled when a procedure is called with the wrong number of arguments.
     3907Signaled when a procedure is called with the wrong number of arguments.
    34433908
    34443909</td></tr><tr><td> (exn type)
    34453910
    3446 Signalled on type-mismatch errors, for example when an argument of the wrong type is passed to a builtin procedure.
     3911Signaled on type-mismatch errors, for example when an argument of the wrong type is passed to a built-in procedure.
    34473912
    34483913</td></tr><tr><td> (exn arithmetic)
    34493914
    3450 Signalled on arithmetic errors, like division by zero.
     3915Signaled on arithmetic errors, like division by zero.
    34513916
    34523917</td></tr><tr><td> (exn i/o)
    34533918
    3454 Signalled on input/output errors.
     3919Signaled on input/output errors.
    34553920
    34563921</td></tr><tr><td> (exn i/o file)
    34573922
    3458 Signalled on file-related errors.
     3923Signaled on file-related errors.
    34593924
    34603925</td></tr><tr><td> (exn i/o net)
    34613926
    3462 Signalled on network errors.
     3927Signaled on network errors.
    34633928
    34643929</td></tr><tr><td> (exn bounds)
    34653930
    3466 Signalled on errors caused by accessing non-existent elements of a collection.
     3931Signaled on errors caused by accessing non-existent elements of a collection.
    34673932
    34683933</td></tr><tr><td> (exn runtime)
    34693934
    3470 Signalled on low-level runtime-system error-situations.
     3935Signaled on low-level runtime-system error-situations.
    34713936
    34723937</td></tr><tr><td> (exn runtime limit)
    34733938
    3474 Signalled when an internal limit is exceeded (like running out of memory).
     3939Signaled when an internal limit is exceeded (like running out of memory).
    34753940
    34763941</td></tr><tr><td> (exn match)
    34773942
    3478 Signalled on errors raised by failed matches (see the section on @code{match}).
     3943Signaled on errors raised by failed matches (see the section on @code{match}).
    34793944
    34803945</td></tr><tr><td> (exn syntax)
    34813946
    3482 Signalled on syntax errors.
     3947Signaled on syntax errors.
    34833948
    34843949</td></tr><tr><td> (exn breakpoint)
    34853950
    3486 Signalled when a breakpoint is reached.
     3951Signaled when a breakpoint is reached.
    34873952
    34883953</td></tr>
     
    34993964@item When the @code{posix} unit is available and used, then a user-interrupt (@code{signal/int}) signals an exception of the kind @code{user-interrupt}.
    35003965
    3501 @item the procedure @code{condition-property-accessor} accepts an optional third argument. If the condition does not have a value for the desired property and if the optional argument is given, no error is signalled and the accessor returns the third argument.
    3502 
    3503 @item In composite conditionss all properties are currently collected in a single property-list, so in the case that to conditions have the same named property, only one will be visible.
     3966@item the procedure @code{condition-property-accessor} accepts an optional third argument. If the condition does not have a value for the desired property and if the optional argument is given, no error is signaled and the accessor returns the third argument.
     3967
     3968@item In composite conditions all properties are currently collected in a single property-list, so in the case that to conditions have the same named property, only one will be visible.
    35043969
    35053970
     
    35123977* Unit library - Environment information and system interface - exit::
    35133978* Unit library - Environment information and system interface - build-platform::
    3514 * Unit library - Environment information and system interface - build-style::
    35153979* Unit library - Environment information and system interface - chicken-version::
    35163980* Unit library - Environment information and system interface - errno::
     
    35343998[procedure] (argv)
    35353999@end verbatim
    3536 Return a list of all supplied command-line arguments. The first item in the list is a string containing the name of the executing program. The other items are the arguments passed to the application. This list is freshly created on every invocation of @code{(argv)}.  It depends on the host-shell whether arguments are expanded ('globbed') or not.
     4000Return a list of all supplied command-line arguments. The first item in the list is a string containing the name of the executing program. The other items are the arguments passed to the application. This list is freshly created on every invocation of @code{(argv)}. It depends on the host-shell whether arguments are expanded ('globbed') or not.
    35374001
    35384002@node Unit library - Environment information and system interface - exit, Unit library - Environment information and system interface - build-platform, Unit library - Environment information and system interface - argv, Unit library - Environment information and system interface
     
    35454009Exit the running process and return exit-code, which defaults to 0 (Invokes @code{exit-handler}).
    35464010
    3547 @node Unit library - Environment information and system interface - build-platform, Unit library - Environment information and system interface - build-style, Unit library - Environment information and system interface - exit, Unit library - Environment information and system interface
     4011Note that pending @code{dynamic-wind} thunks are @emph{not} invoked when exiting your program in this way.
     4012
     4013@node Unit library - Environment information and system interface - build-platform, Unit library - Environment information and system interface - chicken-version, Unit library - Environment information and system interface - exit, Unit library - Environment information and system interface
    35484014@subsection build-platform
    35494015
     
    35564022@verbatim
    35574023cygwin
    3558 msvc
    35594024mingw32
    35604025gnu
    3561 metrowerks
    35624026intel
    3563 watcom
    35644027unknown
    35654028@end verbatim
    3566 @node Unit library - Environment information and system interface - build-style, Unit library - Environment information and system interface - chicken-version, Unit library - Environment information and system interface - build-platform, Unit library - Environment information and system interface
    3567 @subsection build-style
    3568 
    3569 
    3570 @verbatim
    3571  [procedure] (build-style)
    3572 @end verbatim
    3573 Returns a symbol indicating the build system used to create the CHICKEN instance running this program. Possible values are:
    3574 
    3575 @verbatim
    3576  cmake
    3577  autotools
    3578  diy
    3579  custom
    3580 @end verbatim
    3581 @node Unit library - Environment information and system interface - chicken-version, Unit library - Environment information and system interface - errno, Unit library - Environment information and system interface - build-style, Unit library - Environment information and system interface
     4029@node Unit library - Environment information and system interface - chicken-version, Unit library - Environment information and system interface - errno, Unit library - Environment information and system interface - build-platform, Unit library - Environment information and system interface
    35824030@subsection chicken-version
    35834031
     
    36444092[procedure] (on-exit THUNK)
    36454093@end verbatim
    3646 Schedules the zero-argument procexdures @code{THUNK} to be executed before the process exits, either explicitly via @code{exit} or implicitly after exection of the last toplevel form. Note that finalizers for unreferenced finalized data are run before exit procedures.
     4094Schedules the zero-argument procedures @code{THUNK} to be executed before the process exits, either explicitly via @code{exit} or implicitly after execution of the last top-level form. Note that finalizers for unreferenced finalized data are run before exit procedures.
    36474095
    36484096@node Unit library - Environment information and system interface - software-type, Unit library - Environment information and system interface - software-version, Unit library - Environment information and system interface - on-exit, Unit library - Environment information and system interface
     
    37814229[procedure] (error [LOCATION] [STRING] EXP ...)
    37824230@end verbatim
    3783 Prints error message, writes all extra arguments to the value of @code{(current-error-port)} and invokes the current exception-handler.  This conforms to @uref{http://srfi.schemers.org/srfi-23/srfi-23.html, SRFI-23}. If @code{LOCATION} is given and a symbol, it specifies the @emph{location} (the name of the procedure) where the error occurred.
     4231Prints error message, writes all extra arguments to the value of @code{(current-error-port)} and invokes the current exception-handler. This conforms to @uref{http://srfi.schemers.org/srfi-23/srfi-23.html, SRFI-23}. If @code{LOCATION} is given and a symbol, it specifies the @emph{location} (the name of the procedure) where the error occurred.
    37844232
    37854233@node Unit library - Interrupts and error-handling - get-call-chain, Unit library - Interrupts and error-handling - print-call-chain, Unit library - Interrupts and error-handling - error, Unit library - Interrupts and error-handling
     
    37904238[procedure] (get-call-chain [START [THREAD]])
    37914239@end verbatim
    3792 Returns a list with the call history. Backtrace information is only generated in code compiled without @code{-no-trace} and evaluated code. If the optional argument @code{START} is given, the backtrace starts at this offset, i.e. when @code{START} is 1, the next to last trace-entry  is printed, and so on. If the optional argument @code{THREAD} is given, then the call-chain will only be constructed for calls performed by this thread.
     4240Returns a list with the call history. Backtrace information is only generated in code compiled without @code{-no-trace} and evaluated code. If the optional argument @code{START} is given, the backtrace starts at this offset, i.e. when @code{START} is 1, the next to last trace-entry is printed, and so on. If the optional argument @code{THREAD} is given, then the call-chain will only be constructed for calls performed by this thread.
    37934241
    37944242@node Unit library - Interrupts and error-handling - print-call-chain, Unit library - Interrupts and error-handling - print-error-message, Unit library - Interrupts and error-handling - get-call-chain, Unit library - Interrupts and error-handling
     
    38654313[procedure] (gc [FLAG])
    38664314@end verbatim
    3867 Invokes a garbage-collection and returns the number of free bytes in the heap. The flag specifies whether a minor (@code{#f}) or major (@code{#t}) GC is to be triggered. If no argument is given, @code{#t} is assumed. When the argument is @code{#t}, all pending finalizers are executed.
     4315Invokes a garbage-collection and returns the number of free bytes in the heap. The flag specifies whether a minor (@code{#f}) or major (@code{#t}) GC is to be triggered. If no argument is given, @code{#t} is assumed. An explicit @code{#t} argument will cause all pending finalizers to be executed.
    38684316
    38694317@node Unit library - Garbage collection - memory-statistics, Unit library - Garbage collection - set-finalizer!, Unit library - Garbage collection - gc, Unit library - Garbage collection
     
    38744322[procedure] (memory-statistics)
    38754323@end verbatim
    3876 Performs a major garbage collection and returns a three element vector  containing the total heap size in bytes, the number of bytes currently used and the size of the nursery (the first heap generation). Note that the actual heap is actually twice the size given in the heap size, because CHICKEN uses a copying semi-space collector.
     4324Performs a major garbage collection and returns a three element vector containing the total heap size in bytes, the number of bytes currently used and the size of the nursery (the first heap generation). Note that the actual heap is actually twice the size given in the heap size, because CHICKEN uses a copying semi-space collector.
    38774325
    38784326@node Unit library - Garbage collection - set-finalizer!, Unit library - Garbage collection - set-gc-report!, Unit library - Garbage collection - memory-statistics, Unit library - Garbage collection
     
    38834331[procedure] (set-finalizer! X PROC)
    38844332@end verbatim
    3885 Registers a procedure of one argument @code{PROC}, that will be called as soon as the non-immediate data object @code{X} is about to be garbage-collected (with that object as its argument).  Note that the finalizer will @b{not} be called while interrupts are disabled. This procedure returns @code{X}.
     4333Registers a procedure of one argument @code{PROC}, that will be called as soon as the non-immediate data object @code{X} is about to be garbage-collected (with that object as its argument). Note that the finalizer will @b{not} be called while interrupts are disabled. This procedure returns @code{X}.
    38864334
    38874335@node Unit library - Garbage collection - set-gc-report!,  , Unit library - Garbage collection - set-finalizer!, Unit library - Garbage collection
     
    38984346
    38994347@menu
    3900 * Unit library - Other control structures - andmap::
    3901 * Unit library - Other control structures - ormap::
    39024348* Unit library - Other control structures - promise?::
    39034349
     
    39054351
    39064352
    3907 @node Unit library - Other control structures - andmap, Unit library - Other control structures - ormap,  , Unit library - Other control structures
    3908 @subsection andmap
    3909 
    3910 
    3911 @verbatim
    3912 [procedure] (andmap PROC LIST1 ...)
    3913 @end verbatim
    3914 Repeatedly calls @code{PROC} with arguments taken from @code{LIST1 ...}.   If any invocation should return @code{#f}, the result of @code{andmap} is @code{#f}. If all invocations return a true result, then the result of @code{andmap} is @code{#t}.
    3915 
    3916 @node Unit library - Other control structures - ormap, Unit library - Other control structures - promise?, Unit library - Other control structures - andmap, Unit library - Other control structures
    3917 @subsection ormap
    3918 
    3919 
    3920 @verbatim
    3921 [procedure] (ormap PROC LIST1 ...)
    3922 @end verbatim
    3923 Repeatedly calls @code{PROC} with arguments taken from @code{LIST1 ...}.   If any invocation should return a value different from @code{#f}, then this value is returned as the  result of @code{ormap}. If all invocations return @b{#f}, then the result of @code{ormap} is @code{#f}.
    3924 
    3925 @node Unit library - Other control structures - promise?,  , Unit library - Other control structures - ormap, Unit library - Other control structures
     4353@node Unit library - Other control structures - promise?,  ,  , Unit library - Other control structures
    39264354@subsection promise?
    39274355
     
    40034431
    40044432@verbatim
    4005 [procedure] (print EXP1 EXP2 ...)
    4006 @end verbatim
    4007 Outputs the arguments @code{EXP1 EXP2 ...} using @code{display} and writes a newline character to the port that is the value of @code{(current-output-port)}. Returns its first argument.
     4433[procedure] (print [EXP1 ...])
     4434@end verbatim
     4435Outputs the optional arguments @code{EXP1 ...} using @code{display} and writes a newline character to the port that is the value of @code{(current-output-port)}. Returns @code{(void)}.
    40084436
    40094437@node Unit library - Standard Input/Output - print*,  , Unit library - Standard Input/Output - print, Unit library - Standard Input/Output
     
    40124440
    40134441@verbatim
    4014 [procedure] (print* EXP1 ...)
    4015 @end verbatim
    4016 Similar to @code{print}, but does not output a terminating newline character and performs a @code{flush-outout} after writing its arguments.
    4017 
    4018 @node Unit library - User-defined named characters, Unit library - Vectors, Unit library - Standard Input/Output, Unit library
     4442[procedure] (print* [EXP1 ...])
     4443@end verbatim
     4444Similar to @code{print}, but does not output a terminating newline character and performs a @code{flush-output} after writing its arguments.
     4445
     4446@node Unit library - User-defined named characters, Unit library - Blobs, Unit library - Standard Input/Output, Unit library
    40194447@section User-defined named characters
    40204448
     
    40324460[procedure] (char-name SYMBOL-OR-CHAR [CHAR])
    40334461@end verbatim
    4034 This procedure can be used to inquire about character names or to define new ones. With a single argument the behavior is as follows: If @code{SYMBOL-OR-CHAR} is a symbol, then @code{char-name} returns the character with this name, or @code{#f} if no character is defined under this name.  If @code{SYMBOL-OR-CHAR} is a character, then the name of the character is returned as a symbol, or @code{#f} if the character has no associated name.
    4035 
    4036 If the optional argument @code{CHAR} is provided, then @code{SYMBOL-OR-CHAR} should be a symbol that will be the new name of the given character.  If multiple names designate the same character, then the @code{write} will use the character name that was defined last.
    4037 
    4038 <enscript highlight=scheme> (char-name 'space)                  ==> #\space (char-name #\space)                 ==> space (char-name 'bell)                   ==> #f (char-name (integer->char 7))       ==> #f (char-name 'bell (integer->char 7)) (char-name 'bell)                   ==> #\bell (char->integer (char-name 'bell))   ==> 7 </enscript>
    4039 
    4040 @node Unit library - Vectors, Unit library - The unspecified value, Unit library - User-defined named characters, Unit library
     4462This procedure can be used to inquire about character names or to define new ones. With a single argument the behavior is as follows: If @code{SYMBOL-OR-CHAR} is a symbol, then @code{char-name} returns the character with this name, or @code{#f} if no character is defined under this name. If @code{SYMBOL-OR-CHAR} is a character, then the name of the character is returned as a symbol, or @code{#f} if the character has no associated name.
     4463
     4464If the optional argument @code{CHAR} is provided, then @code{SYMBOL-OR-CHAR} should be a symbol that will be the new name of the given character. If multiple names designate the same character, then the @code{write} will use the character name that was defined last.
     4465
     4466@example
     4467(char-name 'space)                  =@strong{=>} #\space
     4468(char-name #\space)                 =@strong{=>} space
     4469(char-name 'bell)                   =@strong{=>} #f
     4470(char-name (integer->char 7))       =@strong{=>} #f
     4471(char-name 'bell (integer->char 7))
     4472(char-name 'bell)                   =@strong{=>} #\bell
     4473(char->integer (char-name 'bell))   =@strong{=>} 7
     4474@end example
     4475@node Unit library - Blobs, Unit library - Vectors, Unit library - User-defined named characters, Unit library
     4476@section Blobs
     4477
     4478@menu
     4479* Unit library - Blobs - make-blob::
     4480* Unit library - Blobs - blob?::
     4481* Unit library - Blobs - blob-size::
     4482* Unit library - Blobs - blob->string::
     4483* Unit library - Blobs - string->blob::
     4484* Unit library - Blobs - blob=?::
     4485
     4486@end menu
     4487
     4488
     4489"blobs" are collections of unstructured bytes. You can't do much with them, but allow conversion to and from SRFI-4 number vectors.
     4490
     4491@node Unit library - Blobs - make-blob, Unit library - Blobs - blob?,  , Unit library - Blobs
     4492@subsection make-blob
     4493
     4494
     4495@verbatim
     4496[procedure] (make-blob SIZE)
     4497@end verbatim
     4498Returns a blob object of @code{SIZE} bytes, aligned on an 8-byte boundary, uninitialized.
     4499
     4500@node Unit library - Blobs - blob?, Unit library - Blobs - blob-size, Unit library - Blobs - make-blob, Unit library - Blobs
     4501@subsection blob?
     4502
     4503
     4504@verbatim
     4505[procedure] (blob? X)
     4506@end verbatim
     4507Returns @code{#t} if @code{X} is a blob object, or @code{#f} otherwise.
     4508
     4509@node Unit library - Blobs - blob-size, Unit library - Blobs - blob->string, Unit library - Blobs - blob?, Unit library - Blobs
     4510@subsection blob-size
     4511
     4512
     4513@verbatim
     4514[procedure] (blob-size BLOB)
     4515@end verbatim
     4516Returns the number of bytes in @code{BLOB}.
     4517
     4518@node Unit library - Blobs - blob->string, Unit library - Blobs - string->blob, Unit library - Blobs - blob-size, Unit library - Blobs
     4519@subsection blob->string
     4520
     4521
     4522@verbatim
     4523[procedure] (blob->string BLOB)
     4524@end verbatim
     4525Returns a string with the contents of @code{BLOB}.
     4526
     4527@node Unit library - Blobs - string->blob, Unit library - Blobs - blob=?, Unit library - Blobs - blob->string, Unit library - Blobs
     4528@subsection string->blob
     4529
     4530
     4531@verbatim
     4532[procedure] (string->blob STRING)
     4533@end verbatim
     4534Returns a blob with the contents of @code{STRING}.
     4535
     4536@node Unit library - Blobs - blob=?,  , Unit library - Blobs - string->blob, Unit library - Blobs
     4537@subsection blob=?
     4538
     4539
     4540@verbatim
     4541[procedure] (blob=? BLOB1 BLOB2)
     4542@end verbatim
     4543Returns @code{#t} if the two argument blobs are of the same size and have the same content.
     4544
     4545@node Unit library - Vectors, Unit library - The unspecified value, Unit library - Blobs, Unit library
    40414546@section Vectors
    40424547
     
    41154620[procedure] (continuation-capture PROCEDURE)
    41164621@end verbatim
    4117 Creates a continuation object representing the current continuation and tail-calls  @code{PROCEDURE} with this continuation as the single argument.
     4622Creates a continuation object representing the current continuation and tail-calls @code{PROCEDURE} with this continuation as the single argument.
    41184623
    41194624More information about this continuation API can be found in the paper @uref{http://repository.readscheme.org/ftp/papers/sw2001/feeley.pdf, http://repository.readscheme.org/ftp/papers/sw2001/feeley.pdf} @emph{A Better API for first class Continuations} by Marc Feeley.
     
    41264631[procedure] (continuation? X)
    41274632@end verbatim
    4128 Returns @code{#t} if @code{X} is a continuation object, or @code{#f} otherwise.
     4633Returns @code{#t} if @code{X} is a continuation object, or @code{#f} otherwise. Please note that this applies only to continuations created by the Continuation API, but not by call/cc, i.e.: @code{(call-with-current-continuation continuation?)} returns @code{#f}, whereas @code{(continuation-capture continuation?)} returns @code{#t}.
    41294634
    41304635@node Unit library - Continuations - continuation-graft, Unit library - Continuations - continuation-return, Unit library - Continuations - continuation?, Unit library - Continuations
     
    41464651Returns the value(s) to the continuation @code{CONT}. @code{continuation-return} could be implemented like this:
    41474652
    4148 <enscript highlight=scheme> (define (continuation-return k . vals)
    4149 
    4150 @verbatim
    4151  (continuation-graft
    4152    k
    4153    (lambda () (apply values vals)) ) )
    4154 @end verbatim
    4155 </enscript>
    4156 
     4653@example
     4654(@strong{define} (@strong{continuation-return} k . vals)
     4655  (continuation-graft
     4656    k
     4657    (@strong{lambda} () (apply values vals)) ) )
     4658@end example
    41574659@node Unit library - Setters, Unit library - Reader extensions, Unit library - Continuations, Unit library
    41584660@section Setters
     
    41874689Returns a copy of the procedure @code{GETTER} with the associated setter procedure @code{SETTER}. Contrary to the SRFI specification, the setter of the returned procedure may be changed.
    41884690
    4189 @node Unit library - Reader extensions,  , Unit library - Setters, Unit library
     4691@node Unit library - Reader extensions, Unit library - Property lists, Unit library - Setters, Unit library
    41904692@section Reader extensions
    41914693
     
    42164718[procedure] (set-read-syntax! CHAR-OR-SYMBOL PROC)
    42174719@end verbatim
    4218 When the reader is encounting the non-whitespace character @code{CHAR} while reading an expression from a given port, then the procedure @code{PROC} will be called with that port as its argument. The procedure should return a value that will be returned to the reader:
    4219 
    4220 <enscript highlight=scheme>
    4221 
    4222 @verbatim
    4223 ; A simple RGB color syntax:
    4224 @end verbatim
    4225 @verbatim
    4226 (set-read-syntax! #\%
    4227   (lambda (port)
    4228     (apply vector
    4229       (map (cut string->number <> 16)
    4230 @end verbatim
     4720When the reader encounters the non-whitespace character @code{CHAR} while reading an expression from a given port, then the procedure @code{PROC} will be called with that port as its argument. The procedure should return a value that will be returned to the reader:
     4721
     4722@example
     4723 @emph{; A simple RGB color syntax:
     4724}
     4725 (set-read-syntax! #\%
     4726   (@strong{lambda} (port)
     4727     (apply vector
     4728       (map (cut string->number <> 16)
    42314729            (string-chop (read-string 6 port) 2) ) ) ) )
    42324730
    4233 @verbatim
    4234 (with-input-from-string "(1 2 %f0f0f0 3)" read)
    4235 ; ==> (1 2 #(240 240 240) 3)
    4236 @end verbatim
    4237 </enscript>
    4238 
     4731 (with-input-from-string @strong{"(1 2 %f0f0f0 3)"} read)
     4732 @emph{; ==> (1 2 #(240 240 240) 3)
     4733}@end example
    42394734If @code{CHAR-OR-SYMBOL} is a symbol, then a so-called @emph{read-mark} handler is defined. In that case the handler procedure will be called when a character-sequence of the form
    42404735
     
    42744769@end verbatim
    42754770Returns a copy of the given read-table. You can access the currently active read-table with @code{(current-read-table)}.
     4771
     4772@node Unit library - Property lists,  , Unit library - Reader extensions, Unit library
     4773@section Property lists
     4774
     4775@menu
     4776* Unit library - Property lists - get::
     4777* Unit library - Property lists - put!::
     4778* Unit library - Property lists - remprop!::
     4779* Unit library - Property lists - symbol-plist::
     4780* Unit library - Property lists - get-properties::
     4781
     4782@end menu
     4783
     4784
     4785As in other Lisp dialects, CHICKEN supports "property lists" associated with symbols. Properties are accessible via a key that can be any kind of value but which will be compared using @code{eq?}.
     4786
     4787@node Unit library - Property lists - get, Unit library - Property lists - put!,  , Unit library - Property lists
     4788@subsection get
     4789
     4790
     4791@verbatim
     4792 [procedure] (get SYMBOL PROPERTY [DEFAULT])
     4793@end verbatim
     4794Returns the value stored under the key @code{PROPERTY} in the property list of @code{SYMBOL}. If no such property is stored, returns @code{DEFAULT}. The @code{DEFAULT} is optional and defaults to @code{#f}.
     4795
     4796@node Unit library - Property lists - put!, Unit library - Property lists - remprop!, Unit library - Property lists - get, Unit library - Property lists
     4797@subsection put!
     4798
     4799
     4800@verbatim
     4801 [procedure] (put! SYMBOL PROPERTY VALUE)
     4802 [setter] (set! (get SYMBOL PROPERTY) VALUE)
     4803@end verbatim
     4804Stores @code{VALUE} under the key @code{PROPERTY} in the property list of @code{SYMBOL} replacing any previously stored value.
     4805
     4806@node Unit library - Property lists - remprop!, Unit library - Property lists - symbol-plist, Unit library - Property lists - put!, Unit library - Property lists
     4807@subsection remprop!
     4808
     4809
     4810@verbatim
     4811 [procedure] (remprop! SYMBOL PROPERTY)
     4812@end verbatim
     4813Deletes the first property matching the key @code{PROPERTY} in the property list of @code{SYMBOL}. Returns @code{#t} when a deletion performed, and @code{#f} otherwise.
     4814
     4815@node Unit library - Property lists - symbol-plist, Unit library - Property lists - get-properties, Unit library - Property lists - remprop!, Unit library - Property lists
     4816@subsection symbol-plist
     4817
     4818
     4819@verbatim
     4820 [procedure] (symbol-plist SYMBOL)
     4821 [setter] (set! (symbol-plist SYMBOL) LST)
     4822@end verbatim
     4823Returns the property list of @code{SYMBOL} or sets it.
     4824
     4825@node Unit library - Property lists - get-properties,  , Unit library - Property lists - symbol-plist, Unit library - Property lists
     4826@subsection get-properties
     4827
     4828
     4829@verbatim
     4830 [procedure] (get-properties SYMBOL PROPERTIES)
     4831@end verbatim
     4832Searches the property list of @code{SYMBOL} for the first property with a key in the list @code{PROPERTIES}. Returns 3 values: the matching property key, value, and the tail of property list after the matching property. When no match found all values are @code{#f}.
     4833
     4834@code{PROPERTIES} may also be an atom, in which case it is treated as a list of one element.
    42764835
    42774836Previous: @ref{Parameters, Parameters}
     
    45105069
    45115070@end table
    4512 Contains a string naming the path to the extension repository, which defaults to either the value of the environment variable @code{CHICKEN_REPOSITORY}, the value of the environment variable @code{CHICKEN_HOME} or the default library path (usually @code{/usr/local/lib/chicken} on UNIX systems).
     5071Contains a string naming the path to the extension repository, which defaults to either the value of the environment variable @code{CHICKEN_REPOSITORY} or the default library path (usually @code{/usr/local/lib/chicken} on UNIX systems).
    45135072
    45145073@node Unit eval - Loading extension libraries - extension-information, Unit eval - Loading extension libraries - provide, Unit eval - Loading extension libraries - repository-path, Unit eval - Loading extension libraries
     
    45505109
    45515110@itemize
    4552 @item the current include path, which defaults to the pathnames given in @code{CHICKEN_INCLUDE_PATH} and @code{CHICKEN_HOME}.
     5111@item the current include path, which defaults to the pathnames given in @code{CHICKEN_INCLUDE_PATH}.
    45535112
    45545113@item the current directory
     
    45675126Registers the handler-procedure @code{PROC} as a extension-specifier with the name @code{SYMBOL}. This facility allows extending the set of valid extension specifiers to be used with @code{require-extension}. When @code{register-extension} is called with an extension specifier of the form @code{(SPEC ...)} and @code{SPEC} has been registered with @code{set-extension-specifier!}, then @code{PROC} will be called with two arguments: the specifier and the previously installed handler (or @code{#f} if no such handler was defined). The handler should return a new specifier that will be processed recursively. If the handler returns a vector, then each element of the vector will be processed recursively.  Alternatively the handler may return a string which specifies a file to be loaded:
    45685127
    4569 <enscript highlight=scheme> (eval-when (compile eval)
    457