Changeset 10415 in project
- Timestamp:
- 04/10/08 22:06:43 (13 years ago)
- Location:
- chicken/branches/elf
- Files:
-
- 332 added
- 64 edited
Legend:
- Unmodified
- Added
- Removed
-
chicken/branches/elf/branch-24012008/Makefile
r7215 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # POSSIBILITY OF SUCH DAMAGE. 25 #26 # Send bugs, suggestions and ideas to:27 #28 # felix@call-with-current-continuation.org29 #30 # Felix L. Winkelmann31 # Unter den Gleichen 132 # 37130 Gleichen33 # Germany34 26 35 27 … … 51 43 @echo " $(MAKE) PLATFORM=solaris" 52 44 @echo " $(MAKE) PLATFORM=cross-linux-mingw" 45 @echo " $(MAKE) PLATFORM=msvc" 53 46 @echo "" 54 47 @echo "For more information, consult the README file." 55 48 @exit 1 49 dist: 50 csi -s scripts/makedist.scm 56 51 else 57 52 all: … … 73 68 fullcheck: 74 69 $(MAKE) -f Makefile.$(PLATFORM) fullcheck 75 dist:76 $(MAKE) -f Makefile.$(PLATFORM) distfiles77 csi -s misc/makedist.scm78 70 libs: 79 71 $(MAKE) -f Makefile.$(PLATFORM) libs -
chicken/branches/elf/branch-24012008/Makefile.bsd
r6569 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # POSSIBILITY OF SUCH DAMAGE. 25 #26 # Send bugs, suggestions and ideas to:27 #28 # felix@call-with-current-continuation.org29 #30 # Felix L. Winkelmann31 # Unter den Gleichen 132 # 37130 Gleichen33 # Germany34 26 35 27 … … 59 51 60 52 chicken-config.h: chicken-defaults.h 61 echo "#define HAVE_DIRENT_H 1" > >$@53 echo "#define HAVE_DIRENT_H 1" >$@ 62 54 echo "#define HAVE_DLFCN_H 1" >>$@ 63 55 echo "#define HAVE_INTTYPES_H 1" >>$@ -
chicken/branches/elf/branch-24012008/Makefile.cross-linux-mingw
r7331 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # POSSIBILITY OF SUCH DAMAGE. 25 #26 # Send bugs, suggestions and ideas to:27 #28 # felix@call-with-current-continuation.org29 #30 # Felix L. Winkelmann31 # Unter den Gleichen 132 # 37130 Gleichen33 # Germany34 26 35 27 … … 91 83 92 84 chicken-config.h: chicken-defaults.h 93 echo "#define HAVE_DIRENT_H 1" > >$@85 echo "#define HAVE_DIRENT_H 1" >$@ 94 86 echo "#define HAVE_INTTYPES_H 1" >>$@ 95 87 echo "#define HAVE_LIMITS_H 1" >>$@ -
chicken/branches/elf/branch-24012008/Makefile.cygwin
r7077 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # POSSIBILITY OF SUCH DAMAGE. 25 #26 # Send bugs, suggestions and ideas to:27 #28 # felix@call-with-current-continuation.org29 #30 # Felix L. Winkelmann31 # Unter den Gleichen 132 # 37130 Gleichen33 # Germany34 26 35 27 … … 90 82 include defaults.make 91 83 92 chicken-config.h: chicken-defaults.h 84 chicken-config.h: chicken-defaults.h buildsvnrevision 85 echo "#define C_SVN_REVISION $(shell cat buildsvnrevision)" >$@ 93 86 echo "#define HAVE_DIRENT_H 1" >>$@ 94 87 echo "#define HAVE_INTTYPES_H 1" >>$@ -
chicken/branches/elf/branch-24012008/Makefile.linux
r7325 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # POSSIBILITY OF SUCH DAMAGE. 25 #26 # Send bugs, suggestions and ideas to:27 #28 # felix@call-with-current-continuation.org29 #30 # Felix L. Winkelmann31 # Unter den Gleichen 132 # 37130 Gleichen33 # Germany34 26 35 27 … … 62 54 63 55 chicken-config.h: chicken-defaults.h 64 echo "#define HAVE_DIRENT_H 1" > >$@56 echo "#define HAVE_DIRENT_H 1" >$@ 65 57 echo "#define HAVE_DLFCN_H 1" >>$@ 66 58 echo "#define HAVE_INTTYPES_H 1" >>$@ -
chicken/branches/elf/branch-24012008/Makefile.macosx
r7773 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # 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 34 27 35 28 # platform configuration … … 67 60 68 61 chicken-config.h: chicken-defaults.h 69 echo "#define HAVE_DIRENT_H 1" > >$@62 echo "#define HAVE_DIRENT_H 1" >$@ 70 63 echo "#define HAVE_DLFCN_H 1" >>$@ 71 64 echo "#define HAVE_INTTYPES_H 1" >>$@ -
chicken/branches/elf/branch-24012008/Makefile.mingw
r7180 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # POSSIBILITY OF SUCH DAMAGE. 25 #26 # Send bugs, suggestions and ideas to:27 #28 # felix@call-with-current-continuation.org29 #30 # Felix L. Winkelmann31 # Unter den Gleichen 132 # 37130 Gleichen33 # Germany34 26 35 27 … … 40 32 HACKED_APPLY = 1 41 33 WINDOWS = 1 34 NO_UNIX_SHELL = 1 42 35 43 36 # file extensions … … 89 82 90 83 chicken-config.h: chicken-defaults.h 91 echo #define HAVE_DIRENT_H 1 > >$@84 echo #define HAVE_DIRENT_H 1 >$@ 92 85 echo #define HAVE_INTTYPES_H 1 >>$@ 93 86 echo #define HAVE_LIMITS_H 1 >>$@ … … 210 203 echo # define C_TARGET_STATIC_LIB_HOME "$(TARGET_PREFIX)/lib" >>$@ 211 204 echo #endif >>$@ 205 echo #ifndef C_BINARY_VERSION >>$@ 206 echo # define C_BINARY_VERSION $(BINARYVERSION) >>$@ 207 echo #endif >>$@ 212 208 213 209 include rules.make -
chicken/branches/elf/branch-24012008/Makefile.mingw-msys
r7180 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # POSSIBILITY OF SUCH DAMAGE. 25 #26 # Send bugs, suggestions and ideas to:27 #28 # felix@call-with-current-continuation.org29 #30 # Felix L. Winkelmann31 # Unter den Gleichen 132 # 37130 Gleichen33 # Germany34 26 35 27 … … 86 78 87 79 chicken-config.h: chicken-defaults.h 88 echo "#define HAVE_DIRENT_H 1" > >$@80 echo "#define HAVE_DIRENT_H 1" >$@ 89 81 echo "#define HAVE_INTTYPES_H 1" >>$@ 90 82 echo "#define HAVE_LIMITS_H 1" >>$@ -
chicken/branches/elf/branch-24012008/Makefile.solaris
r6569 r10415 2 2 # 3 3 # Copyright (c) 2007, Felix L. Winkelmann 4 # Copyright (c) 2008, The Chicken Team 4 5 # All rights reserved. 5 6 # … … 23 24 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 # POSSIBILITY OF SUCH DAMAGE. 25 #26 # Send bugs, suggestions and ideas to:27 #28 # felix@call-with-current-continuation.org29 #30 # Felix L. Winkelmann31 # Unter den Gleichen 132 # 37130 Gleichen33 # Germany34 26 35 27 … … 59 51 60 52 chicken-config.h: chicken-defaults.h 61 echo "#define HAVE_DIRENT_H 1" > >$@53 echo "#define HAVE_DIRENT_H 1" >$@ 62 54 echo "#define HAVE_DLFCN_H 1" >>$@ 63 55 echo "#define HAVE_INTTYPES_H 1" >>$@ -
chicken/branches/elf/branch-24012008/NEWS
r7864 r10415 1 3.0.0rc1 1 3.1.2 2 3 - unit utils: added file-copy and file-move (request by the einit team) 4 5 3.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 11 3.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 42 3.0.0 2 43 3 44 - upgraded scheme-complete.el to version 0.6 [Thanks to Alex Shinn] -
chicken/branches/elf/branch-24012008/README
r7916 r10415 3 3 (c)2000-2008 Felix L. Winkelmann 4 4 5 version 3. 0.15 version 3.1.2 6 6 7 7 … … 71 71 installed, then pass "CHICKEN=<chicken-executable>" to the 72 72 "make" invocation to override this setting. "CHICKEN" defaults 73 to defaults to"$PREFIX/bin/chicken".73 to "$PREFIX/bin/chicken". 74 74 75 75 If you do not have a "chicken" binary installed, enter … … 79 79 which will unpack a tarball containing precompiled C sources 80 80 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. 83 85 84 86 The build may show errors when creating the info(1) … … 111 113 Build only static versions of the runtime library, compiler 112 114 and interpreter. `chicken-setup' will not be generated, 113 as it is mostly u nless compiled code can be loaded.115 as it is mostly useless unless compiled code can be loaded. 114 116 115 117 SYMBOLGC=1 … … 251 253 - For Mac OS X, Chicken requires libdl, for loading compiled 252 254 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: 254 256 255 257 http://www.opendarwin.org/projects/dlcompat … … 257 259 - On Mac OS X, Chicken and its eggs can be built as universal 258 260 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 260 268 make PLATFORM=macosx ARCH=universal 261 269 262 270 - On Mac OS X, Chicken can be built in 64-bit mode on Intel 263 271 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: 265 273 266 274 make PLATFORM=macosx ARCH=x86-64 267 275 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 273 284 - Cygwin will not be able to find the chicken shared libraries 274 285 until Windows is rebooted. … … 282 293 warnings are bogus and can be ignored. 283 294 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. 284 314 285 315 6. Emacs support: … … 335 365 If you have any more questions or problems (even the slightest 336 366 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. 340 369 341 370 -
chicken/branches/elf/branch-24012008/apply-hack.ppc.darwin.s
r5861 r10415 2 2 ; 3 3 ; Copyright (c) 2007, Felix L. Winkelmann 4 ; Copyright (c) 2008 The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 */ 35 27 -
chicken/branches/elf/branch-24012008/apply-hack.ppc.sysv.s
r5861 r10415 2 2 ; 3 3 ; Copyright (c) 2007, Felix L. Winkelmann 4 ; All rights reserved. 4 ; Copyright (c) 2008, The Chicken Team 5 ; All rights reserved. 5 6 ; 6 7 ; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 */ 35 27 -
chicken/branches/elf/branch-24012008/apply-hack.x86-64.s
r7044 r10415 2 2 ; 3 3 ; Copyright (c) 2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 */ 35 27 -
chicken/branches/elf/branch-24012008/apply-hack.x86.s
r5526 r10415 2 2 ; 3 3 ; Copyright (c) 2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 */ 35 27 -
chicken/branches/elf/branch-24012008/banner.scm
r7776 r10415 2 2 3 3 CHICKEN 4 (c)2008 The Chicken Team 5 (c)2000-2007 Felix L. Winkelmann 4 6 5 7 EOF 6 8 ) 7 8 (define-constant +copyright+ "(c)2000-2008 Felix L. Winkelmann") -
chicken/branches/elf/branch-24012008/batch-driver.scm
r7274 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 35 27 … … 381 373 (unless quiet 382 374 (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") ) ) 384 376 (else 385 377 … … 498 490 [proc (user-pass-2)] ) 499 491 (when (debugging 'M "; requirements:") 500 (pretty-print ( hash-table->alist file-requirements)))492 (pretty-print (##sys#hash-table->alist file-requirements))) 501 493 (when proc 502 494 (when verbose (printf "Secondary user pass...~%")) -
chicken/branches/elf/branch-24012008/buildversion
r7916 r10415 1 3. 0.11 3.1.2 -
chicken/branches/elf/branch-24012008/c-backend.scm
r7784 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 35 27 … … 507 499 ((>= n llen)) 508 500 (gen #\, (char->integer (string-ref ll n))) ) 509 (do ((n ( remainder llen 8) (sub1 n))) ; fill up with zeros to align following entry501 (do ((n (- (bitwise-and #xfffff8 (+ llen 7)) llen) (sub1 n))) ; fill up with zeros to align following entry 510 502 ((zero? n)) 511 503 (gen ",0") ) … … 696 688 ((null? lit) 697 689 (gen #t to "=C_SCHEME_END_OF_LIST;") ) 698 (( ##sys#immediate? lit) (bad-literallit))699 ((##core#inline "C_lambdainfop" lit))700 ( else690 ((and (not (##sys#immediate? lit)) 691 (##core#inline "C_lambdainfop" lit))) 692 ((or (fixnum? lit) (not (##sys#immediate? lit))) 701 693 (gen #t to "=C_decode_literal(C_heaptop,") 702 694 (gen-string-constant (encode-literal lit)) 703 (gen ");") ) ) ) 695 (gen ");") ) 696 (else (bad-literal lit)))) 704 697 705 698 (define (gen-string-constant str) … … 1364 1357 ((eof-object? lit) "\xff\x3e") 1365 1358 ((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") ) ) 1373 1368 ((number? lit) 1374 1369 (string-append "\x55" (number->string lit) "\x00") ) -
chicken/branches/elf/branch-24012008/c-platform.scm
r7167 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 35 27 … … 108 100 ##sys#profile-entry ##sys#profile-exit) ) ) ) 109 101 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 111 103 (define words-per-flonum 4) 112 104 (define parameter-limit 1024) -
chicken/branches/elf/branch-24012008/chicken-bug.1
r7036 r10415 57 57 58 58 .SH AUTHOR 59 .I chicken-bug 60 was written by Felix L. Winkelmann (felix@call-with-current-continuation.org).59 Felix L. Winkelmann (felix@call-with-current-continuation.org) 60 and The Chicken Team. 61 61 62 62 .SH SEE ALSO -
chicken/branches/elf/branch-24012008/chicken-bug.scm
r7864 r10415 1 1 ;;;; 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. 2 25 3 26 … … 19 42 20 43 (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") 22 45 23 46 (define-constant +destination+ "chicken-janitors@nongnu.org") -
chicken/branches/elf/branch-24012008/chicken-ffi-macros.scm
r6839 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 35 27 -
chicken/branches/elf/branch-24012008/chicken-more-macros.scm
r7915 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 35 27 … … 377 369 (let ([b (##sys#slot bs 0)] 378 370 [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)] 380 372 [(null? (##sys#slot b 1)) `(if ,(##sys#slot b 0) ,(fold bs2) #f)] 381 373 [else … … 634 626 635 627 (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) ) ) ) ) 698 677 699 678 … … 724 703 725 704 (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)] ) 732 707 (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))] 735 709 [kinds (if var (cadr c) (car c))] 736 710 [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) ) ) 764 725 765 726 -
chicken/branches/elf/branch-24012008/chicken-profile.1
r5945 r10415 55 55 .SH BUGS 56 56 Submit bug reports by e-mail to 57 .I felix@call-with-current-continuation.org57 .I chicken-janitors@nongnu.org 58 58 59 .SH AUTHOR 60 .I csc 61 was written by Felix L. Winkelmann (felix@call-with-current-continuation.org). 59 .SH AUTHORS 60 Felix L. Winkelmann and the Chicken Team 62 61 63 62 .SH SEE ALSO -
chicken/branches/elf/branch-24012008/chicken-profile.scm
r6439 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 35 27 … … 38 30 (uses srfi-1 39 31 srfi-13 32 srfi-69 40 33 posix 41 34 utils)) -
chicken/branches/elf/branch-24012008/chicken-setup.1
r7334 r10415 1 1 .\" dummy line 2 .TH CHICKEN-SETUP 1 "2 5 Jan 2004"2 .TH CHICKEN-SETUP 1 "28 Feb 2008" 3 3 4 4 .SH NAME … … 50 50 .SH OPTIONS 51 51 52 .TP 53 .B \-h,\ \-help 54 Shows a summary of options and exits. 55 56 .TP 57 .B \-V,\ \-version 58 Shows the version of 59 .I chicken-setup 60 and exits. 61 62 .TP 63 .B \-release 64 Shows release number of CHICKEN and exits. 65 66 .TP 67 .BI \-R,\ \-repository \ [PATH] 68 If 69 .B PATH 70 is not given, prints the location of the extension repository. 71 If 72 .B PATH 73 is given, specifies the location for the extension repository 74 The 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 81 Removes the given extension from the repository. 82 83 .TP 84 .BI \-H,\ \-host \ HOSTNAME[:PORT] 85 Specifies alternative host for downloading extensions. 86 .B PORT 87 may be omitted and defaults to 80. 88 89 .TP 90 .BI \-p,\ \-proxy \ HOSTNAME[:PORT] 91 Connects to server via proxy. 92 .B PORT 93 may be omitted and defaults to 80. 94 95 .TP 96 .B \-l,\ \-list 97 Lists all installed extensions and exits, or show extension-information 98 of extensions given on the command-line (following this option). 99 100 .TP 101 .BI \-r,\ \-run \ FILENAME 102 Loads and executes given file. 103 104 .TP 105 .BI \-P,\ \-program\-path \ [PATH] 106 If 107 .B PATH 108 is not given, prints the location where executable files will be installed. 109 If 110 .B PATH 111 is given, specifies the location for installing executable files. 112 113 .TP 114 .BI \-s,\ \-script \ FILENAME 115 Executes the given script with remaining arguments and exits. 116 117 .TP 118 .B \-f,\ \-fetch 119 Only download, don't extract, build or install. 120 121 .TP 122 .B \-v,\ \-verbose 123 Displays additional information (mainly for debugging). 124 125 .TP 126 .B \-k,\ \-keep 127 Keeps intermediate files after building and installing. 128 52 129 .TP 53 .BI \-c sc\-optionoption130 .BI \-c,\ \-csc\-option \ option 54 131 Passes 55 132 .B option … … 62 139 63 140 .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 142 Does not ask the user before trying to download required extensions. 143 144 .TP 145 .BI \-n,\ \-no\-install 146 Does not install generated binaries and support files after building. 147 Any invocations of 118 148 .I install\-program 119 149 , 120 150 .I install\-extension 151 , 152 .I install\-script 121 153 or 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 155 will be no-ops. 156 157 .TP 158 .B \-i,\ \-docindex 159 Displays the path to the index-page of any installed 160 extension-documentation. If the index page does not exist, it is 161 created. 162 163 .TP 164 .BI \-e,\ \-eval \ EXPRESSION 165 Evaluates the given expression(s). 166 167 .TP 168 .BI \-t,\ \-test 169 If the 170 .B .egg 171 extension archive contains a directory named 174 172 .B tests 175 173 and this directory includes a file named … … 180 178 181 179 .TP 182 .BI \-tree\ filename 180 .B \-host\-extension 181 Compiles any extensions in "host" mode. 182 183 .TP 184 .BI \-ls \ EXTENSION 185 Lists the installed files for the given extension. 186 187 .TP 188 .B \-fetch\-tree 189 Downloads and prints the repository catalog to standard output. 190 191 .TP 192 .BI \-create\-tree \ PATH 193 Creates repository catalog from SVN checkout. 194 195 .TP 196 .BI \-tree \ FILENAME 183 197 Uses the repository catalog stored in 184 .B filename198 .B FILENAME 185 199 instead of downloading it. 186 200 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 204 Fetches extension sources from an SVN repository instead of 205 downloading egg from egg server. 206 207 .TP 208 .BI \-local \ PATH 209 Fetches extension sources from the local filesystem at 210 .B PATH 211 instead of downloading egg from egg server. 212 213 .TP 214 .BI \-install-prefix \ PATH 215 Specifies alternative installation prefix. The installation paths for 216 all executable files, examples, and files installed with the 217 .I copy-file 218 and 219 .I move-file 220 procedures will be prepended by this prefix, if it is specified. 221 222 .TP 223 .BI \-revision \ REVISION 224 Specifies the SVN revision that to check out (only useful in 225 combination with the 226 .B \-svn 227 option). 228 229 .TP 230 .BI \-build\-prefix \ PATH 231 Specifies the location where 232 .I chicken-setup 233 will create build directories. The default location is the value 234 of environment variable 235 .I CHICKEN_TMPDIR 236 , 237 .I TMPDIR 238 or 239 .I /tmp/chicken-{MAJOR-VERSION}-build-{USER} 240 if none of those variables are found in the environment. If 241 .I /tmp 242 does 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 249 Specifies the location where chicken-setup will save downloaded files 250 The default is 251 .I {BUILD-PREFIX}/downloads) 252 198 253 199 254 .TP 200 255 .B \-\- 201 Ignore all further arguments.256 Ignores all further arguments. 202 257 203 258 .SH ENVIRONMENT\ VARIABLES … … 205 260 .TP 206 261 .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. 262 The installation prefix where CHICKEN Scheme and its support files and 263 libraries are located. Defaults to the installation time prefix given 264 when configuring the system. 265 266 .TP 267 .B CHICKEN_INSTALL_PREFIX 268 An alternative installation prefix that will be prepended to extension 269 installation paths if specified. 210 270 211 271 .TP … … 222 282 . 223 283 284 .TP 285 .B CHICKEN_TMPDIR 286 The location where egg files will be unpacked and extensions compiled. 287 224 288 .SH DOCUMENTATION 225 289 … … 229 293 .SH BUGS 230 294 Submit bug reports by e-mail to 231 .I felix@call-with-current-continuation.org295 .I chicken-janitors@nongnu.org 232 296 , preferrably using the 233 297 .B chicken\-bug 234 298 tool. 235 299 236 .SH AUTHOR 237 .I chicken\-setup 238 was written by Felix L. Winkelmann (felix@call-with-current-continuation.org). 300 .SH AUTHORS 301 Felix L. Winkelmann and the Chicken Team 239 302 240 303 .SH SEE ALSO -
chicken/branches/elf/branch-24012008/chicken-setup.scm
r7764 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 35 27 … … 38 30 (uses srfi-1 regex utils posix tcp match srfi-18 srfi-13) 39 31 (export move-file run:execute make/proc uninstall-extension 40 install-extension install-program install-script 41 setup- verbose-flag setup-install-flag installation-prefix42 find- library find-header program-path remove-file* patch43 yes-or-no? setup-build-directory setup-root-directory44 create-directorytest-compile try-compile copy-file run-verbose45 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) ) 47 39 48 40 … … 119 111 120 112 (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 125 120 126 121 (define-constant short-options … … 136 131 ("chicken-bug" . ,(foreign-value "C_CHICKEN_BUG_PROGRAM" c-string)))) 137 132 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) ) )142 133 143 134 (define *cc* (foreign-value "C_TARGET_CC" c-string)) … … 154 145 (build-platform) ) ) 155 146 156 (define *windows-shell* (eq? *windows* 'mingw32)) 147 (define *windows-shell* (or (eq? *windows* 'mingw32) 148 (eq? *windows* 'msvc))) 157 149 (define *debug* #f) 158 150 159 151 (register-feature! 'chicken-setup) 160 152 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 162 191 (define (cross-chicken) (##sys#fudge 39)) 163 192 (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))169 193 170 194 (define *copy-command* (if *windows-shell* 'copy "cp -r")) … … 174 198 (define *tar-program* 'tar) 175 199 (define *fetch-only* #f) 176 (define *temporary-directory* #f) 177 (define *tmpdir-created* #f) 200 (define *builddir-created* #f) 178 201 (define *keep-stuff* #f) 179 202 (define *csc-options* '()) … … 185 208 (define *proxy-host* #f) 186 209 (define *proxy-port* #f) 187 (define *example-directory* (make-pathname (chicken-home) "examples"))188 210 (define *base-directory* (current-directory)) 189 211 (define *fetch-tree-only* #f) 190 212 (define *svn-repository* #f) 191 213 (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))) 195 215 (define *revision* #f) 196 216 (define *run-tests* #f) … … 198 218 199 219 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 200 246 ;;; File-system routines 201 202 (define create-directory/parents203 (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))) ) ) )209 247 210 248 (define create-directory … … 215 253 (lambda (dir) 216 254 (verb dir) 217 (create-directory/parents dir) ) 255 (system* "mkdir ~a" (quotewrap dir))) 218 256 (lambda (dir) 219 257 (verb dir) … … 221 259 222 260 261 223 262 ;;; Helper stuff 224 263 264 (define (quotewrapped? str) 265 (and (string? str) (string-prefix? "\"" str) (string-suffix? "\"" str) )) 266 225 267 (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))) 230 273 231 274 (define (abort-setup) … … 273 316 (cons* (quotewrap 274 317 (make-pathname 275 *install-bin-path*318 chicken-bin-path 276 319 (cdr (assoc prg *installed-executables*)))) 277 320 "-feature" "compiling-extension" … … 279 322 " ") ) 280 323 ((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))))) 282 325 (else prg) ) ) 283 326 … … 456 499 (filter-map 457 500 (lambda (d) 458 (and-let* ((mf (or (file-exists? (make-pathname dd "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"))))) 460 503 (display mf (current-error-port)) 461 504 (newline (current-error-port)) … … 470 513 ,(conc e ".egg") 471 514 ,@(if needs (cdr needs) '()))))) 472 *eggs*)515 eggs) 473 516 (write-char #\)))) 474 517 … … 480 523 usage: chicken-setup [OPTION ...] FILENAME 481 524 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 493 538 -f -fetch only download, don't extract, build or install 494 -v -verbose be verbose495 -k -keep don't delete intermediate files496 -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 ...))') 497 542 -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 512 563 513 564 Builds and installs extension libraries. … … 524 575 525 576 (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))) 531 578 532 579 (define (with-ext filename ext) … … 567 614 (write-setup-info (with-output-to-file setup-file 568 615 (cut pp info)))) 569 (unless *windows-shell* (run (chmod a+r , setup-file)))616 (unless *windows-shell* (run (chmod a+r ,(quotewrap setup-file)))) 570 617 write-setup-info)))) 571 618 … … 591 638 (values '() oinfo) ) ) ) ) 592 639 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 597 649 598 650 (define (chdir dir) … … 600 652 (change-directory dir) ) 601 653 602 (define ( rmtmpdir)654 (define (clear-builddir) 603 655 (unless (string=? (current-directory) *base-directory*) 604 656 (chdir *base-directory*) ) 605 (when * tmpdir-created*606 (set! * tmpdir-created* #f)657 (when *builddir-created* 658 (set! *builddir-created* #f) 607 659 (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))) 609 661 (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))) )) ) )) 612 664 613 665 (define (unpack/enter filename) … … 615 667 (with-input-from-file fn 616 668 (lambda () (string=? "\x1f\x8b" (read-string 2))) ) ) 617 (let ((tmpdir (compute- tmpdir filename)))669 (let ((tmpdir (compute-builddir filename))) 618 670 (cond ((file-exists? tmpdir) 619 671 (chdir tmpdir) … … 621 673 (else 622 674 (create-directory tmpdir) 623 (set! * tmpdir-created* #t)675 (set! *builddir-created* #t) 624 676 (chdir tmpdir) 625 677 (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)) 627 682 (v (setup-verbose-flag)) ) 628 683 (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))) 634 689 (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))) 636 694 (ensure-directory to) 637 695 (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)) 639 699 (err (error "file does not exist" from)) 640 700 (else (warning "file does not exist" from))))) 641 701 642 702 (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)))) 645 707 (ensure-directory to) 646 708 (run (,*move-command* ,(quotewrap from) ,(quotewrap to)) ) ) ) … … 686 748 (when (and (not *windows*) 687 749 (equal? "so" (pathname-extension to))) 688 (run (,*remove-command* , to)))750 (run (,*remove-command* ,(quotewrap to)) )) 689 751 (copy-file from to) 690 752 (unless *windows-shell* 691 (run (chmod a+r , to)))753 (run (chmod a+r ,(quotewrap to)))) 692 754 (and-let* ((static (assq 'static info))) 693 755 (when (and (eq? (software-version) 'macosx) 694 756 (equal? (cadr static) from) 695 757 (equal? (pathname-extension to) "a")) 696 (run (ranlib , to)) ))758 (run (ranlib ,(quotewrap to)) ) )) 697 759 (make-dest-pathname rpath f))) 698 760 files) ) ) … … 707 769 (set! *rebuild-doc-index* #t)) ) 708 770 (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) )) 717 783 (write-info id dests info) ) ) ) 718 784 … … 724 790 (when (setup-install-flag) 725 791 (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))) 727 794 (files (if *windows* 728 795 (map (lambda (f) … … 737 804 (copy-file from to) 738 805 (unless *windows-shell* 739 (run (chmod a+r , to)))806 (run (chmod a+r ,(quotewrap to)))) 740 807 to) ) 741 808 files) ) ) … … 745 812 (when (setup-install-flag) 746 813 (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))) 748 816 (pfiles (map (lambda (f) 749 817 (let ((from (if (pair? f) (car f) f)) … … 751 819 (copy-file from to) 752 820 (unless *windows-shell* 753 (run (chmod a+r , to)))821 (run (chmod a+r ,(quotewrap to)))) 754 822 to) ) 755 823 files) ) ) … … 778 846 779 847 (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)) 784 850 (repository-path))) ) 785 851 (ensure-directory p) … … 794 860 (create-directory dir) 795 861 (unless *windows-shell* 796 (run (chmod a+x , dir)))))))862 (run (chmod a+x ,(quotewrap dir)))))))) 797 863 798 864 (define (try-compile code #!key c++ (cc (if c++ *cxx* *cc*)) (cflags "") (ldflags "") … … 835 901 ((ext version . more) 836 902 (let ((info (extension-information ext)) 837 ( version (->string version)) )903 (required-version (->string version)) ) 838 904 (if info 839 905 (let ((ver (and (assq 'version info) (cadr (assq 'version info))))) 840 906 (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))) 842 910 (upgrade-message 843 911 ext 844 912 (sprintf "is older than ~a, which is what this extension requires" 845 version) ) )913 required-version) ) ) 846 914 (else (loop more)) ) ) 847 915 (upgrade-message ext "is not installed") ) ) ) … … 942 1010 (cond (*local-repository* 943 1011 (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 946 1016 (*svn-repository* 947 1017 (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"))) 949 1020 (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 951 1024 (else 952 1025 (match hostdata … … 968 1041 (close-input-port i) 969 1042 (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)) 973 1050 (loop) ) ) ) ) ) ) 974 1051 (x (error "(internal) invalid host" x)) ) ) ) ) … … 998 1075 *last-decent-host* 999 1076 (pathname-file ext) 1000 (pathname-replace-extension ext "egg") ) 1001 #t) 1077 (pathname-replace-extension ext "egg") )) 1078 1002 1079 (else 1003 1080 (download-repository-tree) … … 1011 1088 (print "installing required extensions ...") 1012 1089 (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))) ) 1014 1091 (else 1015 1092 (error "Extension does not exist in the repository" ext)) ) ) ) ) ) ) … … 1023 1100 (cond ((and df (with-ext filename "setup")) => run-setup-script) 1024 1101 ((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"))))) 1026 1120 (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)))))))) 1044 1122 1045 1123 … … 1065 1143 (let ((rpath (repository-path)) 1066 1144 (hn (get-host-name))) 1067 (with-output-to-file (doc-stylesheet )1145 (with-output-to-file (doc-stylesheet #t) 1068 1146 (lambda () (display #<<EOF 1069 1147 body, html { … … 1142 1220 } 1143 1221 EOF 1144 1145 (with-output-to-file (doc-index )1222 ))) 1223 (with-output-to-file (doc-index #t) 1146 1224 (lambda () 1147 1225 (print "<html><head><title>Egg documentation index for " hn … … 1176 1254 string<?) ) ) 1177 1255 (display "</tbody></table></body></font></html>\n") ) ) ) ) ) 1178 1179 1256 1180 1257 ;;; Output stuff … … 1287 1364 (print (program-path)) 1288 1365 (exit) ) 1289 (("-destdir" path . more) 1290 (set! *example-directory* (make-pathname path "examples")) 1291 (set! *destdir* path) 1366 (("-install-prefix" path . more) 1292 1367 (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) 1293 1374 (loop more) ) 1294 1375 (("-program-path" dir . more) … … 1347 1428 (loop more) ) 1348 1429 (("-docindex" . more) 1349 (let ((di (doc-index )))1430 (let ((di (doc-index #t))) 1350 1431 (unless (file-exists? di) 1351 1432 (build-doc-index) ) … … 1379 1460 (host-extension #t) 1380 1461 (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")) 1382 1464 (error "missing option argument" (car args)) ) 1383 1465 ((filename . more) … … 1428 1510 (main (append (string-split (or (getenv "CHICKEN_SETUP_OPTIONS") "")) 1429 1511 (command-line-arguments) ) ) ) ) 1430 ( rmtmpdir) )1512 (clear-builddir) ) -
chicken/branches/elf/branch-24012008/chicken.1
r7180 r10415 428 428 .I Chicken\ User's\ Manual 429 429 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 432 Felix L. Winkelmann and The Chicken Team. 442 433 443 434 .SH SEE ALSO -
chicken/branches/elf/branch-24012008/chicken.h
r7777 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 */ 35 36 27 37 28 /* Configuration: */ … … 93 84 # undef C_externimport 94 85 # undef C_externexport 95 # define C_externimport C_extern __declspec(dllimport)96 86 # define C_externexport C_extern __declspec(dllexport) 97 87 # undef C_varextern … … 100 90 # define C_varextern C_extern __declspec(dllexport) 101 91 # define C_fctexport __declspec(dllexport) 92 # define C_externimport C_extern __declspec(dllexport) 102 93 # else 103 94 # define C_varextern C_extern __declspec(dllimport) 104 95 # define C_fctexport __declspec(dllimport) 96 # define C_externimport C_extern __declspec(dllimport) 105 97 # endif 106 98 # elif defined(__WATCOMC__) … … 174 166 #if defined(__APPLE__) && defined(__MACH__) 175 167 # 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_MACOS179 168 #endif 180 169 … … 208 197 #if defined(__MINGW32__) 209 198 # include <sys/param.h> 199 #elif defined(__CYGWIN__) 200 # include <endian.h> 210 201 #elif defined(__linux__) 211 202 # include <endian.h> … … 242 233 #endif 243 234 244 #ifdef C_MACOS245 # include <alloca.h>246 int strncasecmp(const char *one, const char *two, size_t n);247 #endif248 249 235 #ifdef __MINGW32__ 250 236 # include <malloc.h> … … 262 248 typedef unsigned __int16 uint16_t; 263 249 typedef __int32 int32_t; 264 typedef unsigned __int32 int32_t;265 typedef __int64 uint64_t;250 typedef unsigned __int32 uint32_t; 251 typedef __int64 int64_t; 266 252 typedef unsigned __int64 uint64_t; 267 253 # pragma warning(disable: 4101) … … 489 475 #define C_RUNTIME_SAFE_DLOAD_UNSAFE_ERROR 34 490 476 #define C_BAD_ARGUMENT_TYPE_NO_FLONUM_ERROR 35 477 #define C_BAD_ARGUMENT_TYPE_NO_CLOSURE_ERROR 36 491 478 492 479 … … 1057 1044 #endif 1058 1045 1046 #define C_i_check_closure(x) C_i_check_closure_2(x, C_SCHEME_FALSE) 1059 1047 #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) 1060 1049 #define C_i_check_number(x) C_i_check_number_2(x, C_SCHEME_FALSE) 1061 1050 #define C_i_check_string(x) C_i_check_string_2(x, C_SCHEME_FALSE) … … 1290 1279 C_fctexport C_word C_exit_runtime(C_word code); 1291 1280 C_fctexport C_word C_fcall C_display_flonum(C_word port, C_word n) C_regparm; 1281 C_fctexport C_word C_fcall C_set_print_precision(C_word n) C_regparm; 1282 C_fctexport C_word C_fcall C_get_print_precision(void) C_regparm; 1292 1283 C_fctexport C_word C_fcall C_read_char(C_word port) C_regparm; 1293 1284 C_fctexport C_word C_fcall C_peek_char(C_word port) C_regparm; … … 1455 1446 C_fctexport C_word C_fcall C_i_length(C_word lst) C_regparm; 1456 1447 C_fctexport C_word C_fcall C_i_inexact_to_exact(C_word n) C_regparm; 1448 C_fctexport C_word C_fcall C_i_check_closure_2(C_word x, C_word loc) C_regparm; 1457 1449 C_fctexport C_word C_fcall C_i_check_exact_2(C_word x, C_word loc) C_regparm; 1450 C_fctexport C_word C_fcall C_i_check_inexact_2(C_word x, C_word loc) C_regparm; 1458 1451 C_fctexport C_word C_fcall C_i_check_number_2(C_word x, C_word loc) C_regparm; 1459 1452 C_fctexport C_word C_fcall C_i_check_string_2(C_word x, C_word loc) C_regparm; … … 1506 1499 C_fctexport C_word C_fcall C_i_o_fixnum_plus(C_word x, C_word y) C_regparm; 1507 1500 C_fctexport C_word C_fcall C_i_o_fixnum_difference(C_word x, C_word y) C_regparm; 1501 C_fctexport C_word C_fcall C_i_o_fixnum_and(C_word x, C_word y) C_regparm; 1502 C_fctexport C_word C_fcall C_i_o_fixnum_ior(C_word x, C_word y) C_regparm; 1503 C_fctexport C_word C_fcall C_i_o_fixnum_xor(C_word x, C_word y) C_regparm; 1508 1504 1509 1505 C_fctexport C_word C_fcall C_i_foreign_char_argumentp(C_word x) C_regparm; -
chicken/branches/elf/branch-24012008/chicken.scm
r6827 r10415 2 2 ; 3 3 ; Copyright (c) 2000-2007, Felix L. Winkelmann 4 ; Copyright (c) 2008, The Chicken Team 4 5 ; All rights reserved. 5 6 ; … … 23 24 ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 25 ; POSSIBILITY OF SUCH DAMAGE. 25 ;26 ; Send bugs, suggestions and ideas to:27 ;28 ; felix@call-with-current-continuation.org29 ;30 ; Felix L. Winkelmann31 ; Unter den Gleichen 132 ; 37130 Gleichen33 ; Germany34 26 35 27 … … 79 71 (include "chicken-more-macros") 80 72 (include "chicken-ffi-macros") ) 81 82 ;;(##sys#provide 'extras 'srfi-1 'srfi-4)83 73 84 74 -
chicken/branches/elf/branch-24012008/chicken.texi
r5923 r10415 1 1 \input texinfo @c -*- texinfo -*- 2 @setfilename chicken.info3 2 @settitle Chicken Scheme Reference Manual 4 3 @setchapternewpage on 5 @ifinfo6 @format7 INFO-DIR-SECTION Programming8 START-INFO-DIR-ENTRY9 * Chicken: (chicken.info). A compiler that translates Scheme source files into C.10 END-INFO-DIR-ENTRY11 @end format12 @end ifinfo13 4 @copying 14 Copyright 2007 Felix Winkelmann5 Copyright 2007-2008 Felix Winkelmann and the Chicken Team 15 6 @end copying 16 7 @titlepage 17 8 @sp 10 18 9 @title{Chicken Scheme Reference Manual} 19 @author{Felix Winkelmann }10 @author{Felix Winkelmann and the Chicken Team} 20 11 @comment The following two commands start the copyright page. 21 12 @page 22 13 @vskip 0pt plus 1fill 23 Copyright 2007 Felix Winkelmann14 Copyright 2007-2008 Felix Winkelmann and the Chicken Team 24 15 @end titlepage 25 16 @node Top, The User's Manual, (dir), (dir) … … 28 19 @menu 29 20 * The User's Manual:: 21 * Getting started:: 30 22 * Basic mode of operation:: 31 23 * Using the compiler:: … … 49 41 * Unit regex:: 50 42 * Unit srfi-18:: 43 * Unit srfi-69:: 51 44 * Unit posix:: 52 45 * Unit utils:: … … 68 61 * Bibliography:: 69 62 @end menu 70 @node The User's Manual, Basic mode of operation, Top, Top63 @node The User's Manual, Getting started, Top, Top 71 64 @chapter The User's Manual 72 65 73 66 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: 67 This 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 72 What is CHICKEN and how do I use it? 73 @item @ref{Basic mode of operation, Basic mode of operation} 74 75 Compiling Scheme files. 76 @item @ref{Using the compiler, Using the compiler} 77 78 Explains how to use CHICKEN to compile programs and execute them. 79 @item @ref{Using the interpreter, Using the interpreter} 80 81 Invocation and usage of @code{csi}, the CHICKEN interpreter 82 @item @ref{Supported language, Supported language} 83 84 The 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 87 Accessing C and C++ code and data. 88 @item @ref{chicken-setup, chicken-setup} 89 90 Packaging and installing extension libraries. 91 @item @ref{Data representation, Data representation} 92 93 How Scheme data is internally represented. 94 @item @ref{Bugs and limitations, Bugs and limitations} 95 96 Yes, there are some. 97 @item @ref{FAQ, FAQ} 98 99 A list of Frequently Asked Questions about CHICKEN (and their answers!). 100 @item @ref{Acknowledgements, Acknowledgements} 101 102 A list of some of the people that have contributed to make CHICKEN what it is. 103 @item @ref{Bibliography, Bibliography} 104 105 Links 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 125 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. 126 127 This 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 133 Scheme 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 81 134 82 135 @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 144 In 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 146 Scheme 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 148 Even 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 150 A 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 152 The 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 158 Chicken 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 162 Chicken 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 164 Chicken 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 180 This package is distributed under the @b{BSD license} and as such is free to use and modify. 181 182 Scheme 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. 86 188 87 189 … … 89 191 The generated C code is fully tail-recursive. 90 192 91 Some of the features supported by C HICKEN:193 Some of the features supported by Chicken: 92 194 93 195 @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. 95 197 96 198 @item Lightweight threads based on first-class continuations … … 106 208 @item UNIX system calls and extended data structures 107 209 108 @item Create interpreted or compiled shell scripts written in Scheme for UNIX or Windows210 @item Create interpreted or compiled shell scripts written in Scheme for UNIX or Windows 109 211 110 212 @item Compiled C files can be easily distributed … … 116 218 117 219 @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 220 Chicken 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 239 Chicken 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 241 This 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 272 At 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 274 At 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 276 The 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 278 A 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 280 The 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 286 Chicken 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 288 Because 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 318 Refer 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 324 The 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 326 You 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 328 As 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 341 In 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 352 To invoke the Chicken interpreter, you use the @code{csi} command. 353 354 @verbatim 355 $ csi 356 CHICKEN 357 (c)2008 The Chicken Team 358 (c)2000-2007 Felix L. Winkelmann 359 Version 3.1.2 - macosx-unix-gnu-x86 [ manyargs dload ptables applyhook ] 360 SVN rev. 10185 compiled 2008-03-27 on argyre.local (Darwin) 361 #;1> 362 @end verbatim 363 This 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) 368 300 369 @end verbatim 370 Suppose 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 378 We 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) 384 6 385 @end verbatim 386 The @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 388 The 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 401 6 402 @end verbatim 403 The 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 409 You 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 413 xyzabcghi 414 abxawxcgh 415 foonly 416 $ csi -ss quickrep.scm <quickrep.dat 'a.*c' A 417 xyzAghi 418 Agh 419 foonly 420 @end verbatim 421 The @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 440 The @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 446 There 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 455 The 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 457 Compiled 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 459 We 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 462 chicken$ csc -dynamic fact.scm 463 chicken$ csi -quiet 464 #;1> (load "fact.so") 465 ; loading fact.so ... 466 #;2> (fact 6) 467 720 468 @end verbatim 469 On 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 487 We 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 492 level is a palindrome 493 $ ./palindrome liver 494 liver isn't a palindrome 495 @end verbatim 496 Chicken 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 498 Here'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 511 Next 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 523 Now 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 530 level 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 536 Installing 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 538 In 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 544 The extension uri does not exist. 545 Do you want to download it ? (yes/no/abort) [yes] yes 546 downloading 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 553 First, @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 555 Now 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 572 Because 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 574 Let'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 577 int 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 589 Now 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 600 The 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 606 0 1 1 2 3 5 8 13 21 34 55 607 @end verbatim 608 Those who are interfacing to substantial C libraries should consider using the easyffi egg, or SWIG. 609 610 Back 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 159 613 @chapter Basic mode of operation 160 614 … … 164 618 The 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: 165 619 166 <enscript highlight=scheme> (declare (uses UNITNAME)) </enscript> 167 620 @example 621 (declare (uses UNITNAME)) 622 @end example 168 623 The 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: 169 624 170 <enscript highlight=scheme> (declare (unit UNITNAME)) </enscript> 171 625 @example 626 (declare (unit UNITNAME)) 627 @end example 172 628 When 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. 173 629 174 630 Another 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: 175 631 176 <enscript highlight=scheme> (include "FILENAME") </enscript> 177 632 @example 633 (include @strong{"FILENAME"}) 634 @end example 178 635 Macro 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}). 179 636 180 637 On 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. 181 638 182 Previous: @ref{ The User's Manual, The User's Manual} Next: @ref{Using the compiler, Using the compiler}639 Previous: @ref{Getting started, Getting started} Next: @ref{Using the compiler, Using the compiler} 183 640 184 641 @node Using the compiler, Using the interpreter, Basic mode of operation, Top … … 207 664 208 665 @verbatim 209 chicken FILENAME @{OPTION@}666 chicken FILENAME {OPTION} 210 667 @end verbatim 211 668 @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}. … … 232 689 233 690 Aborts compilation process after macro-expansion and syntax checks. 234 @item -compress-literals THRESHOLD235 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.237 691 @item -debug MODES 238 692 … … 355 809 @item -include-path PATHNAME 356 810 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.811 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{;}. 358 812 @item -inline 359 813 … … 361 815 @item -inline-limit THRESHOLD 362 816 363 Sets the maximum size of a potentially inlinable procedure. Th is option is only effective when inlining has been enabled with the @code{-inline} option. The default threshold is @code{10}.817 Sets the maximum size of a potentially inlinable procedure. The default threshold is @code{10}. 364 818 @item -keyword-style STYLE 365 819 … … 534 988 535 989 @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;:: 537 991 * Using the compiler - Examples - An example with multiple files:: 538 992 … … 540 994 541 995 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 - Examples996 @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 543 997 @subsection A simple example (with one source file) 544 998 545 999 @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:: 549 1003 550 1004 @end menu … … 553 1007 To compile a Scheme program (assuming a UNIX-like environment) consisting of a single source file, perform the following steps. 554 1008 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; 556 1010 @subsubsection Writing your source file 557 1011 … … 559 1013 In this example we will assume your source file is called @code{foo.scm}: 560 1014 561 <enscript highlight=scheme> ;;; foo.scm 562 563 (define (fac n) 564 565 @verbatim 566 (if (zero? n)567 1568 (* 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; 573 1027 @subsubsection Compiling your program 574 1028 … … 585 1039 foo foo.scm 586 1040 @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; 588 1042 @subsubsection Running your program 589 1043 … … 597 1051 If 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). 598 1052 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 - Examples1053 @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 600 1054 @subsection An example with multiple files 601 1055 … … 617 1071 The 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: 618 1072 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 634 1082 @code{bar.scm} will be our library: 635 1083 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 658 1096 @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 659 1097 @subsubsection Compiling and running your program … … 720 1158 It 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: 721 1159 722 Let's take a simple "Hello, world!": 723 724 <enscript highlight=scheme> ; hello.scm 725 726 (print "Hello, world!") </enscript> 727 1160 Let'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 728 1170 Compiled 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}: 729 1171 730 1172 @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 749 1182 Now we have all files together, and can create an tarball containing all the files: 750 1183 … … 753 1186 % gzip hello.tar 754 1187 @end verbatim 755 This is ofnaturally 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.1188 This 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. 756 1189 757 1190 Note 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. … … 802 1235 803 1236 Evaluate @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 1239 Evaluate @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 1242 Evaluate @code{EXPRESSIONS} and print the results of each expression using @code{pretty-print}. Implies @code{-batch} and @code{-quiet}. 804 1243 @item -D -feature SYMBOL 805 1244 806 Registers @code{SYMBOL} to be a valid feature identifier for @code{cond-expand} .1245 Registers @code{SYMBOL} to be a valid feature identifier for @code{cond-expand} and @code{feature?}. 807 1246 @item -h -help 808 1247 … … 810 1249 @item -I -include-path PATHNAME 811 1250 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.1251 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{;}. 813 1252 @item -k -keyword-style STYLE 814 1253 … … 822 1261 @item -q -quiet 823 1262 824 Do not print a startup message. 1263 Do not print a startup message. Also disables generation of call-trace information for interpreted code. 825 1264 @item -s -script PATHNAME 826 1265 … … 863 1302 @verbatim 864 1303 C:>type foo.bat 865 @ @;csibatch %0 %1 %2 %3 %4 %5 %6 %7 %8 %91304 @;csibatch %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 866 1305 (print (eval (with-input-from-string 867 1306 (car (command-line-arguments)) … … 941 1380 942 1381 @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 1397 k 1398 958 1399 @table @b 959 1400 @item ,utr SYMBOL ... … … 1011 1452 @verbatim 1012 1453 #;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)))) 1014 1457 #;3> ,d (make-point 1 2) 1015 1458 a point with x=1 and y=2 … … 1026 1469 (use readline regex) 1027 1470 (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")) 1029 1473 @end verbatim 1030 1474 More details are available in @uref{http://www.call-with-current-continuation.org/eggs/readline.html, the egg's documentation}. … … 1077 1521 @item @ref{Parameters, Parameters} 1078 1522 1079 @item @ref{Unit library, Unit library} basic Scheme definitions1080 1081 @item @ref{Unit eval, Unit eval} evaluation and macro-handling1082 1083 @item @ref{Unit extras, Unit extras} useful utility definitions1084 1085 @item @ref{Unit srfi-1, Unit srfi-1} List Library1523 @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 1086 1530 1087 1531 @item @ref{Unit srfi-4, Unit srfi-4} Homogeneous numeric vectors … … 1089 1533 @item @ref{Unit srfi-13, Unit srfi-13} String library 1090 1534 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 1098 1544 1099 1545 @item @ref{Unit posix, Unit posix} Unix-like services … … 1101 1547 @item @ref{Unit utils, Unit utils} Shell scripting and file operations 1102 1548 1103 @item @ref{Unit tcp, Unit tcp} basic TCP-sockets1104 1105 @item @ref{Unit lolevel, Unit lolevel} low-level operations1549 @item @ref{Unit tcp, Unit tcp} Basic TCP-sockets 1550 1551 @item @ref{Unit lolevel, Unit lolevel} Low-level operations 1106 1552 1107 1553 … … 1115 1561 1116 1562 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 1563 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}). 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 1126 1569 @verbatim 1127 1570 (letrec ((x 1) (y 2)) (cons x y)) … … 1144 1587 (cons x y) ) ) 1145 1588 @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 1169 1609 Previous: @ref{Supported language, Supported language} 1170 1610 … … 1177 1617 [2.1] Identifiers may contain special characters if delimited with @code{| ... |}. 1178 1618 1179 [2.3] The brackets @code{[ ... ]} a re 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}. 1180 1620 1181 1621 [4] Numerous non-standard macros are provided. See @ref{Non-standard macros and special forms, Non-standard macros and special forms} for more information. 1182 1622 1183 [4.1.4] Extended DSSSL style lambda lists are supported. DSSSL formal argumentlists 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 1193 <rest- formal-argument> ==> <ident>1194 <key -formal-argument> ==> <ident>1195 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>) 1196 1636 <initializer> ==> <expr> 1197 1637 @end verbatim 1198 When a procedure is applied to a list of a ctual arguments, the formal and actualarguments are processed from left to right as follows:1638 When a procedure is applied to a list of arguments, the parameters and arguments are processed from left to right as follows: 1199 1639 1200 1640 @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. 1208 1648 1209 1649 1210 1650 @end itemize 1211 It shall be an error for an @code{<ident>} to appear more than once in a formal-argument-list. 1651 Needing 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 1653 It shall be an error for an @code{<ident>} to appear more than once in a parameter-list. 1654 1655 If 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. 1212 1656 1213 1657 Example: … … 1283 1727 1284 1728 [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. 1285 1731 1286 1732 Previous: @ref{Deviations from the standard, Deviations from the standard} … … 1398 1844 This is a simple string with an embedded `##' character 1399 1845 and substituted expressions: (+ three 99) ==> #(+ three 99) 1400 (three is "# @{three@}")1846 (three is "#{three}") 1401 1847 EOF 1402 1848 ) … … 1518 1964 1519 1965 @menu 1520 * Non-standard macros and special forms - Making extra libraries and extensions available e::1966 * Non-standard macros and special forms - Making extra libraries and extensions available:: 1521 1967 * Non-standard macros and special forms - Binding forms for optional arguments:: 1522 1968 * Non-standard macros and special forms - Other binding forms:: … … 1529 1975 1530 1976 1531 @node Non-standard macros and special forms - Making extra libraries and extensions available e, Non-standard macros and special forms - Binding forms for optional arguments, , Non-standard macros and special forms1532 @section Making extra libraries and extensions available e1977 @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 1533 1979 1534 1980 @menu 1535 * Non-standard macros and special forms - Making extra libraries and extensions available e- require-extension::1536 * Non-standard macros and special forms - Making extra libraries and extensions available e- 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:: 1537 1983 1538 1984 @end menu 1539 1985 1540 1986 1541 @node Non-standard macros and special forms - Making extra libraries and extensions available e - 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 availablee1987 @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 1542 1988 @subsection require-extension 1543 1989 … … 1547 1993 [syntax] (use ID ...) 1548 1994 @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).1995 This 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). 1550 1996 1551 1997 During interpretation/evaluation @code{require-extension} performs one of the following: … … 1556 2002 @item If @code{ID} names one of the syntactic extensions @code{chicken-more-macros chicken-ffi-macros}, then this extension will be loaded. 1557 2003 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)}. 1563 2009 1564 2010 1565 2011 @end itemize 1566 During compilation one of the following happens instead:2012 During compilation, one of the following happens instead: 1567 2013 1568 2014 @itemize … … 1571 2017 @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. 1572 2018 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. 1574 2020 1575 2021 @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. … … 1596 2042 When 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. 1597 2043 1598 @node Non-standard macros and special forms - Making extra libraries and extensions available e - 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 availablee2044 @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 1599 2045 @subsection define-extension 1600 2046 … … 1605 2051 This 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 1606 2052 1607 <enscript highlight=scheme> (dynamic EXPRESSION ...) </enscript> 1608 2053 @example 2054 (dynamic EXPRESSION ...) 2055 @end example 1609 2056 are inserted into the output as a @code{begin} form. 1610 2057 1611 2058 If compiled statically (specifically if the feature @code{chicken-compile-shared} has not been given), then this form expands into the following: 1612 2059 1613 <enscript highlight=scheme> (declare (unit NAME)) (provide 'NAME) </enscript> 1614 2060 @example 2061 (declare (unit NAME)) 2062 (provide 'NAME) 2063 @end example 1615 2064 and all clauses of the form 1616 2065 1617 <enscript highlight=scheme> (static EXPRESSION ...) </enscript> 1618 2066 @example 2067 (static EXPRESSION ...) 2068 @end example 1619 2069 all additionally inserted into the expansion. 1620 2070 1621 2071 As a convenience, the clause 1622 2072 1623 <enscript highlight=scheme> (export IDENTIFIER ...) </enscript> 1624 2073 @example 2074 (export IDENTIFIER ...) 2075 @end example 1625 2076 is 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). 1626 2077 1627 2078 Note that the compiler option @code{-extension NAME} is equivalent to prefixing the compiled file with 1628 2079 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 1632 2084 @section Binding forms for optional arguments 1633 2085 … … 1650 2102 Use 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. 1651 2103 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 1654 2109 @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 1655 2110 @subsection case-lambda … … 1661 2116 Expands into a lambda that invokes the body following the first matching lambda-list. 1662 2117 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 1675 2131 For more information see the documentation for @uref{http://srfi.schemers.org/srfi-16/srfi-16.html, SRFI-16} 1676 2132 … … 1684 2140 Binding 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. 1685 2141 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 1693 2146 @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 1694 2147 @subsection let-optionals* … … 1700 2153 Binding 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. 1701 2154 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 1709 2159 @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 1710 2160 @section Other binding forms … … 1791 2241 Binds multiple variables to the result values of @code{EXP ...}. The variables are bound sequentially. 1792 2242 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 1801 2248 @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 1802 2249 @subsection letrec-values … … 1808 2255 Binds the result values of @code{EXP ...} to multiple variables at once. All variables are mutually recursive. 1809 2256 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 1820 2264 @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 1821 2265 @subsection parameterize … … 1839 2283 The syntax 1840 2284 1841 <enscript highlight=scheme> (receive VALUEEXP) </enscript> 1842 2285 @example 2286 (receive VALUEEXP) 2287 @end example 1843 2288 is equivalent to 1844 2289 1845 <enscript highlight=scheme> (receive _ VALUEEXP _) </enscript> 1846 2290 @example 2291 (receive _ VALUEEXP _) 2292 @end example 1847 2293 @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 1848 2294 @subsection set!-values … … 1937 2383 Equivalent to: 1938 2384 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 1941 2388 @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 1942 2389 @subsection when … … 1948 2395 Equivalent to: 1949 2396 1950 <enscript highlight=scheme> (if TEST (begin EXP1 EXP2 ...)) </enscript> 1951 2397 @example 2398 (@strong{if} TEST (@strong{begin} EXP1 EXP2 ...)) 2399 @end example 1952 2400 @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 1953 2401 @section Record structures … … 1970 2418 Defines 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)}. 1971 2419 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 1974 2428 @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 1975 2429 @subsection define-record-printer … … 1982 2436 Defines 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. 1983 2437 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)))) 2447 s =@strong{=>} @strong{"#,(foo 1 2 3)"} 2448 (equal? f (with-input-from-string 2449 s read))) =@strong{=>} #t 2450 @end example 2002 2451 @code{define-record-printer} works also with SRFI-9 record types. 2003 2452 … … 2063 2512 The 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. 2064 2513 2065 In addition the following feature-identifiers may exist: @code{applyhook}, @code{extraslot}, @code{ptables}, @code{dload} , @code{libffi}.2514 In addition the following feature-identifiers may exist: @code{applyhook}, @code{extraslot}, @code{ptables}, @code{dload}. 2066 2515 2067 2516 For further information, see the documentation for @uref{http://srfi.schemers.org/srfi-0/srfi-0.html, SRFI-0}. … … 2139 2588 Pattern 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. 2140 2589 2590 Note: this pattern matching package is not compatible with hygienic macro-expanders like the @code{syntax-case} extension (available separately). 2591 2141 2592 The basic form of pattern matching expression is: 2142 2593 2143 <enscript highlight=scheme> (match exp [pat body] ...) </enscript> 2144 2594 @example 2595 (match exp [pat body] ...) 2596 @end example 2145 2597 where @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: 2146 2598 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 2157 2606 The 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. 2158 2607 … … 2227 2676 a vector of n+k or more elements 2228 2677 | ,pat a pattern 2229 | ,@ @pat a pattern, spliced2678 | ,@pat a pattern, spliced 2230 2679 @end verbatim 2231 2680 The 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. … … 2235 2684 The @code{match-lambda} and @code{match-lambda*} forms are convenient combinations of @code{match} and @code{lambda}, and can be explained as follows: 2236 2685 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 2239 2690 where @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. 2240 2691 2241 2692 The @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: 2242 2693 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 2245 2697 binds @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. 2246 2698 … … 2263 2715 @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: 2264 2716 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 2272 2721 binds @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. 2273 2722 … … 2298 2747 @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: 2299 2748 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 2302 2753 mutates the @code{cadadr} of @code{x} to 4, so that @code{x} is @code{'(1 (2 4))}. 2303 2754 … … 2312 2763 If 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: 2313 2764 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 } 2768 Failed match: 2769 Error: no matching clause for @strong{:} 1 2770 @end example 2323 2771 For most situations, this behavior is adequate, but it can be changed by altering the value of the parameter @code{match-error-control}: 2324 2772 … … 2329 2777 2330 2778 @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 2782 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: 2332 2783 2333 2784 <table> … … 2367 2818 2368 2819 @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 2823 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. 2370 2824 2371 2825 @node Pattern matching - Record Structures Pattern, Pattern matching - Code Generation, Pattern matching - Match Failure, Pattern matching … … 2381 2835 Pattern 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: 2382 2836 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 2838 null? pair? number? string? symbol? boolean? char? procedure? vector? list? 2839 equal? 2840 car cdr cadr cdddr ... 2841 vector-length vector-ref 2842 reverse length call/cc 2843 @end example 2385 2844 Additionally, 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. 2386 2845 … … 2401 2860 * Declarations - c-options:: 2402 2861 * Declarations - check-c-syntax:: 2403 * Declarations - compress-literals::2404 2862 * Declarations - constant:: 2405 2863 * Declarations - export:: … … 2492 2950 Declares 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. 2493 2951 2494 @node Declarations - check-c-syntax, Declarations - co mpress-literals, Declarations - c-options, Declarations2952 @node Declarations - check-c-syntax, Declarations - constant, Declarations - c-options, Declarations 2495 2953 @section check-c-syntax 2496 2954 … … 2502 2960 Enables or disables syntax-checking of embedded C/C++ code fragments. Checking C syntax is the default. 2503 2961 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 2514 2963 @section constant 2515 2964 … … 2789 3238 Certain 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: 2790 3239 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 2793 3246 Parameters are fully thread-local, each thread of execution owns a local copy of a parameters' value. 2794 3247 … … 2906 3359 * Unit library - Standard Input/Output:: 2907 3360 * Unit library - User-defined named characters:: 3361 * Unit library - Blobs:: 2908 3362 * Unit library - Vectors:: 2909 3363 * Unit library - The unspecified value:: … … 2911 3365 * Unit library - Setters:: 2912 3366 * Unit library - Reader extensions:: 3367 * Unit library - Property lists:: 2913 3368 2914 3369 @end menu … … 2929 3384 * Unit library - Arithmetic - signum:: 2930 3385 * Unit library - Arithmetic - finite?:: 3386 * Unit library - Arithmetic - flonum-print-precision:: 2931 3387 2932 3388 @end menu … … 2952 3408 2953 3409 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. 3410 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). 2955 3411 2956 3412 @table @b … … 3064 3520 3065 3521 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.3522 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. 3067 3523 3068 3524 @table @b … … 3115 3571 [procedure] (signum N) 3116 3572 @end verbatim 3117 Returns @code{1} if @code{N} is positive, @code{-1} if @code{N} 3118 3119 @node Unit library - Arithmetic - finite?, 3573 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. 3574 3575 @node Unit library - Arithmetic - finite?, Unit library - Arithmetic - flonum-print-precision, Unit library - Arithmetic - signum, Unit library - Arithmetic 3120 3576 @subsection finite? 3121 3577 … … 3125 3581 @end verbatim 3126 3582 Returns @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 3591 Returns the existing number of digits after the decimal place used in printing a @code{flonum}. 3592 3593 The optional @code{non-negative-fixnum} @code{PRECISION} sets the current print precision. 3127 3594 3128 3595 @node Unit library - File Input/Output, Unit library - Files, Unit library - Arithmetic, Unit library … … 3147 3614 [procedure] (current-output-port [PORT]) 3148 3615 @end verbatim 3149 Returns default 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.3616 Returns default output port. If @code{PORT} is given, then that port is selected as the new current output port. 3617 3618 Note 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. 3152 3619 3153 3620 @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 … … 3160 3627 Returns default error output port. If @code{PORT} is given, then that port is selected as the new current error output port. 3161 3628 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.3629 Note 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. 3163 3630 3164 3631 @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 … … 3178 3645 [procedure] (port-name [PORT]) 3179 3646 @end verbatim 3180 Fetch filename from @code{PORT}. This returns the filename that was used to open this file. 3647 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)}. 3181 3648 3182 3649 @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 … … 3286 3753 3287 3754 3288 CHICKEN maintains a global list of @emph{features} naming functionality available in tthe 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.3755 CHICKEN 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. 3289 3756 3290 3757 @node Unit library - Feature identifiers - features, Unit library - Feature identifiers - feature?, , Unit library - Feature identifiers … … 3336 3803 3337 3804 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.3805 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. 3339 3806 3340 3807 @node Unit library - Keywords - get-keyword, Unit library - Keywords - keyword?, , Unit library - Keywords … … 3345 3812 [procedure] (get-keyword KEYWORD ARGLIST [THUNK]) 3346 3813 @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 3814 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. 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 3356 3822 Note: the @code{KEYWORD} may actually be any kind of object. 3357 3823 … … 3404 3870 Evaluates @code{EXPRESSION} and handles any exceptions that are covered by @code{CLAUSE ...}, where @code{CLAUSE} should be of the following form: 3405 3871 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 3873 CLAUSE = ([VARIABLE] (KIND ...) BODY ...) 3874 @end example 3875 If 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 } 3420 3888 (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 3427 3892 @node Unit library - Exceptions - breakpoint, , Unit library - Exceptions - condition-case, Unit library - Exceptions 3428 3893 @subsection breakpoint … … 3434 3899 Programmatically triggers a breakpoint (similar to the @code{,br} top-level csi command). 3435 3900 3436 All error-conditions signal led by the system are of kind @code{exn}. The following composite conditions are additionally defined:3901 All error-conditions signaled by the system are of kind @code{exn}. The following composite conditions are additionally defined: 3437 3902 3438 3903 <table> … … 3440 3905 <tr><td> (exn arity) 3441 3906 3442 Signal led when a procedure is called with the wrong number of arguments.3907 Signaled when a procedure is called with the wrong number of arguments. 3443 3908 3444 3909 </td></tr><tr><td> (exn type) 3445 3910 3446 Signal led on type-mismatch errors, for example when an argument of the wrong type is passed to a builtin procedure.3911 Signaled on type-mismatch errors, for example when an argument of the wrong type is passed to a built-in procedure. 3447 3912 3448 3913 </td></tr><tr><td> (exn arithmetic) 3449 3914 3450 Signal led on arithmetic errors, like division by zero.3915 Signaled on arithmetic errors, like division by zero. 3451 3916 3452 3917 </td></tr><tr><td> (exn i/o) 3453 3918 3454 Signal led on input/output errors.3919 Signaled on input/output errors. 3455 3920 3456 3921 </td></tr><tr><td> (exn i/o file) 3457 3922 3458 Signal led on file-related errors.3923 Signaled on file-related errors. 3459 3924 3460 3925 </td></tr><tr><td> (exn i/o net) 3461 3926 3462 Signal led on network errors.3927 Signaled on network errors. 3463 3928 3464 3929 </td></tr><tr><td> (exn bounds) 3465 3930 3466 Signal led on errors caused by accessing non-existent elements of a collection.3931 Signaled on errors caused by accessing non-existent elements of a collection. 3467 3932 3468 3933 </td></tr><tr><td> (exn runtime) 3469 3934 3470 Signal led on low-level runtime-system error-situations.3935 Signaled on low-level runtime-system error-situations. 3471 3936 3472 3937 </td></tr><tr><td> (exn runtime limit) 3473 3938 3474 Signal led when an internal limit is exceeded (like running out of memory).3939 Signaled when an internal limit is exceeded (like running out of memory). 3475 3940 3476 3941 </td></tr><tr><td> (exn match) 3477 3942 3478 Signal led on errors raised by failed matches (see the section on @code{match}).3943 Signaled on errors raised by failed matches (see the section on @code{match}). 3479 3944 3480 3945 </td></tr><tr><td> (exn syntax) 3481 3946 3482 Signal led on syntax errors.3947 Signaled on syntax errors. 3483 3948 3484 3949 </td></tr><tr><td> (exn breakpoint) 3485 3950 3486 Signal led when a breakpoint is reached.3951 Signaled when a breakpoint is reached. 3487 3952 3488 3953 </td></tr> … … 3499 3964 @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}. 3500 3965 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 signal led and the accessor returns the third argument.3502 3503 @item In composite conditions sall 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. 3504 3969 3505 3970 … … 3512 3977 * Unit library - Environment information and system interface - exit:: 3513 3978 * Unit library - Environment information and system interface - build-platform:: 3514 * Unit library - Environment information and system interface - build-style::3515 3979 * Unit library - Environment information and system interface - chicken-version:: 3516 3980 * Unit library - Environment information and system interface - errno:: … … 3534 3998 [procedure] (argv) 3535 3999 @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)}. 4000 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. 3537 4001 3538 4002 @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 … … 3545 4009 Exit the running process and return exit-code, which defaults to 0 (Invokes @code{exit-handler}). 3546 4010 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 4011 Note 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 3548 4014 @subsection build-platform 3549 4015 … … 3556 4022 @verbatim 3557 4023 cygwin 3558 msvc3559 4024 mingw32 3560 4025 gnu 3561 metrowerks3562 4026 intel 3563 watcom3564 4027 unknown 3565 4028 @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 3582 4030 @subsection chicken-version 3583 4031 … … 3644 4092 [procedure] (on-exit THUNK) 3645 4093 @end verbatim 3646 Schedules the zero-argument proce xdures @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.4094 Schedules 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. 3647 4095 3648 4096 @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 … … 3781 4229 [procedure] (error [LOCATION] [STRING] EXP ...) 3782 4230 @end verbatim 3783 Prints error message, writes all extra arguments to the value of @code{(current-error-port)} and invokes the current exception-handler. 4231 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. 3784 4232 3785 4233 @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 … … 3790 4238 [procedure] (get-call-chain [START [THREAD]]) 3791 4239 @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 4240 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. 3793 4241 3794 4242 @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 … … 3865 4313 [procedure] (gc [FLAG]) 3866 4314 @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.4315 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. An explicit @code{#t} argument will cause all pending finalizers to be executed. 3868 4316 3869 4317 @node Unit library - Garbage collection - memory-statistics, Unit library - Garbage collection - set-finalizer!, Unit library - Garbage collection - gc, Unit library - Garbage collection … … 3874 4322 [procedure] (memory-statistics) 3875 4323 @end verbatim 3876 Performs a major garbage collection and returns a three element vector 4324 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. 3877 4325 3878 4326 @node Unit library - Garbage collection - set-finalizer!, Unit library - Garbage collection - set-gc-report!, Unit library - Garbage collection - memory-statistics, Unit library - Garbage collection … … 3883 4331 [procedure] (set-finalizer! X PROC) 3884 4332 @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). 4333 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}. 3886 4334 3887 4335 @node Unit library - Garbage collection - set-gc-report!, , Unit library - Garbage collection - set-finalizer!, Unit library - Garbage collection … … 3898 4346 3899 4347 @menu 3900 * Unit library - Other control structures - andmap::3901 * Unit library - Other control structures - ormap::3902 4348 * Unit library - Other control structures - promise?:: 3903 4349 … … 3905 4351 3906 4352 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 3926 4354 @subsection promise? 3927 4355 … … 4003 4431 4004 4432 @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 4435 Outputs 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)}. 4008 4436 4009 4437 @node Unit library - Standard Input/Output - print*, , Unit library - Standard Input/Output - print, Unit library - Standard Input/Output … … 4012 4440 4013 4441 @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-out out} after writing its arguments.4017 4018 @node Unit library - User-defined named characters, Unit library - Vectors, Unit library - Standard Input/Output, Unit library4442 [procedure] (print* [EXP1 ...]) 4443 @end verbatim 4444 Similar 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 4019 4447 @section User-defined named characters 4020 4448 … … 4032 4460 [procedure] (char-name SYMBOL-OR-CHAR [CHAR]) 4033 4461 @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 4462 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. 4463 4464 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. 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 4498 Returns 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 4507 Returns @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 4516 Returns 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 4525 Returns 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 4534 Returns 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 4543 Returns @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 4041 4546 @section Vectors 4042 4547 … … 4115 4620 [procedure] (continuation-capture PROCEDURE) 4116 4621 @end verbatim 4117 Creates a continuation object representing the current continuation and tail-calls 4622 Creates a continuation object representing the current continuation and tail-calls @code{PROCEDURE} with this continuation as the single argument. 4118 4623 4119 4624 More 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. … … 4126 4631 [procedure] (continuation? X) 4127 4632 @end verbatim 4128 Returns @code{#t} if @code{X} is a continuation object, or @code{#f} otherwise. 4633 Returns @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}. 4129 4634 4130 4635 @node Unit library - Continuations - continuation-graft, Unit library - Continuations - continuation-return, Unit library - Continuations - continuation?, Unit library - Continuations … … 4146 4651 Returns the value(s) to the continuation @code{CONT}. @code{continuation-return} could be implemented like this: 4147 4652 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 4157 4659 @node Unit library - Setters, Unit library - Reader extensions, Unit library - Continuations, Unit library 4158 4660 @section Setters … … 4187 4689 Returns 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. 4188 4690 4189 @node Unit library - Reader extensions, 4691 @node Unit library - Reader extensions, Unit library - Property lists, Unit library - Setters, Unit library 4190 4692 @section Reader extensions 4191 4693 … … 4216 4718 [procedure] (set-read-syntax! CHAR-OR-SYMBOL PROC) 4217 4719 @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 4720 When 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) 4231 4729 (string-chop (read-string 6 port) 2) ) ) ) ) 4232 4730 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 4239 4734 If @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 4240 4735 … … 4274 4769 @end verbatim 4275 4770 Returns 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 4785 As 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 4794 Returns 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 4804 Stores @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 4813 Deletes 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 4823 Returns 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 4832 Searches 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. 4276 4835 4277 4836 Previous: @ref{Parameters, Parameters} … … 4510 5069 4511 5070 @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).5071 Contains 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). 4513 5072 4514 5073 @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 … … 4550 5109 4551 5110 @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}. 4553 5112 4554 5113 @item the current directory … … 4567 5126 Registers 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: 4568 5127 4569 <enscript highlight=scheme> (eval-when (compile eval) 457