- Timestamp:
- 03/12/09 13:11:25 (11 years ago)
- Location:
- chicken/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
chicken/trunk/manual/Accessing external objects
r13683 r13710 86 86 even have to specify an lvalue. 87 87 88 <enscript highlight=scheme>89 #>90 enum { abc=3, def, ghi };91 <#92 93 (define-macro (define-simple-foreign-enum . items)94 `(begin95 ,@(map (match-lambda96 [(name realname) `(define-foreign-variable ,name int ,realname)]97 [name `(define-foreign-variable ,name int)] )98 items) ) )99 100 (define-simple-foreign-enum abc def ghi)101 102 ghi ==> 5103 </enscript>104 105 88 106 89 === foreign-lambda -
chicken/trunk/manual/Bugs and limitations
r13709 r13710 14 14 Previous: [[Data representation]] 15 15 16 Next: [[ faq]]16 Next: [[FAQ]] -
chicken/trunk/manual/The User's Manual
r13683 r13710 1 1 [[tags:manual]] 2 2 3 == The User's Manual 3 [[image:http://www.call-with-current-continuation.org/chicken.png]] 4 5 == The CHICKEN User's Manual 4 6 5 7 This is the user's manual for the Chicken Scheme compiler, version 4.0.0x5 -
chicken/trunk/manual/Unit eval
r13683 r13710 109 109 changes the current exception-handler to display a message, write 110 110 any arguments to the value of {{(current-error-port)}} and reset. 111 112 113 === Macros114 115 ==== get-line-number116 117 [procedure] (get-line-number EXPR)118 119 If {{EXPR}} is a pair with the car being a symbol, and line-number120 information is available for this expression, then this procedure returns121 the associated line number. If line-number information is not available,122 then {{#f}} is returned. Note that line-number information for123 expressions is only available in the compiler.124 125 ==== macro?126 127 [procedure] (macro? SYMBOL)128 129 Returns {{#t}} if there exists a macro-definition for {{SYMBOL}}.130 131 ==== expand132 133 [procedure] (expand X)134 135 If {{X}} is a macro-form, expand the macro (and repeat expansion136 until expression is a non-macro form). Returns the resulting expression.137 138 ==== undefine-macro!139 140 [procedure] (undefine-macro! SYMBOL)141 142 Remove the current macro-definition of the macro named {{SYMBOL}}.143 144 ==== syntax-error145 146 [procedure] (syntax-error [LOCATION] MESSAGE ARGUMENT ...)147 148 Signals an exception of the kind {{(exn syntax)}}. Otherwise identical to149 {{error}}.150 111 151 112 -
chicken/trunk/manual/Unit expand
r13686 r13710 4 4 == Unit expand 5 5 6 This unit has support for macro- and module handling. This unit is used6 This unit has support for syntax- and module handling. This unit is used 7 7 by default, unless the program is compiled with the {{-explicit-use}} 8 8 option. … … 20 20 expressions is only available in the compiler. 21 21 22 ==== macro?23 24 [procedure] (macro? SYMBOL)25 26 Returns {{#t}} if there exists a macro-definition for {{SYMBOL}}.27 28 22 ==== expand 29 23 … … 32 26 If {{X}} is a macro-form, expand the macro (and repeat expansion 33 27 until expression is a non-macro form). Returns the resulting expression. 34 35 ==== undefine-macro!36 37 [procedure] (undefine-macro! SYMBOL)38 39 Remove the current macro-definition of the macro named {{SYMBOL}}.40 28 41 29 ==== syntax-error -
chicken/trunk/manual/Unit library
r13709 r13710 80 80 81 81 {{most-positive-fixnum}} 82 82 83 {{most-negative-fixnum}} 84 83 85 {{fixnum-bits}} 86 84 87 {{fixnum-precision}} 85 88 -
chicken/trunk/manual/faq
r13709 r13710 226 226 227 227 <enscript highlight=scheme> 228 % cat userpass.scm229 ;;;; userpass.scm - My very own compiler pass230 231 (declare (unit userpass))232 233 ;; Perhaps more user passes/extensions are added:234 (let ([old (user-pass)])235 (user-pass236 (lambda (x)237 (let ([x2 (do-something-with x)])238 (if old239 (old x2)240 x2) ) ) ) )228 % cat userpass.scm 229 ;;;; userpass.scm - My very own compiler pass 230 231 (declare (unit userpass)) 232 233 ;; Perhaps more user passes/extensions are added: 234 (let ([old (user-pass)]) 235 (user-pass 236 (lambda (x) 237 (let ([x2 (do-something-with x)]) 238 (if old 239 (old x2) 240 x2) ) ) ) ) 241 241 </enscript> 242 242 … … 264 264 265 265 It is not sufficient for the included file to require the {{syntax-case}} extension. Call {{(require-extension syntax-case)}} ''before'' calling {{include}}. 266 267 ==== Why are macros not visible outside of the compilation unit in which they are defined?268 269 Macros are defined during compile time, so when a file has been compiled, the definitions are gone. An exception270 to this rule are macros defined with {{define-macro}}, which are also visible at run-time, i.e.271 in {{eval}}. To use macros defined in other files, use the {{include}} special272 form.273 266 274 267 === Warnings and errors … … 305 298 declarations) and use this feature only if the application works properly. 306 299 307 ==== Why do I get a warning when I define a global variable named {{match}}?308 309 Even when the {{match}} unit is not used, the macros from that package are visible in the compiler.310 The reason for this is that macros can not be accessed from library units (only when explicitly evaluated in running311 code). To speed up macro-expansion time, the compiler and the interpreter both already provide the compiled312 {{match-...}} macro definitions. Macros shadowed lexically are no problem, but global definitions313 of variables named identically to (global) macros are useless - the macro definition shadows the global314 variable.315 316 This problem can be solved using a different name or undefining the macro, like this:317 318 <enscript highlight=scheme>319 (eval-when (compile eval) (undefine-macro! 'match))320 </enscript>321 300 ==== Why don't toplevel-continuations captured in interpreted code work? 322 301 … … 342 321 343 322 <enscript highlight=scheme> 344 (eval-when (compile)345 (define-reader-ctor 'integer->char integer->char) )346 (print #,(integer->char 33))323 (eval-when (compile) 324 (define-reader-ctor 'integer->char integer->char) ) 325 (print #,(integer->char 33)) 347 326 </enscript> 348 327 … … 352 331 353 332 <enscript highlight=scheme> 354 (eval-when (compile)355 (define-reader-ctor 'integer->char integer->char) )356 357 (include "other-file")358 </enscript> 359 360 <enscript highlight=scheme> 361 ;;; other-file.scm:362 (print #,(integer->char 33))333 (eval-when (compile) 334 (define-reader-ctor 'integer->char integer->char) ) 335 336 (include "other-file") 337 </enscript> 338 339 <enscript highlight=scheme> 340 ;;; other-file.scm: 341 (print #,(integer->char 33)) 363 342 </enscript> 364 343 … … 368 347 369 348 <enscript highlight=scheme> 370 #;1> (use srfi-18)371 ; loading library srfi-18 ...372 Error: (load-library) unable to load library373 srfi-18374 "dlopen(libchicken.dylib, 9): image not found" ;; on a Mac375 "libchicken.so: cannot open shared object file: No such file or directory" ;; Linux349 #;1> (use srfi-18) 350 ; loading library srfi-18 ... 351 Error: (load-library) unable to load library 352 srfi-18 353 "dlopen(libchicken.dylib, 9): image not found" ;; on a Mac 354 "libchicken.so: cannot open shared object file: No such file or directory" ;; Linux 376 355 </enscript> 377 356 … … 438 417 and compiler settings: 439 418 440 441 442 443 444 445 446 447 448 449 450 451 452 419 {{+}} {{*}} {{-}} {{/}} {{quotient}} {{eq?}} {{eqv?}} {{equal?}} {{apply}} {{c...r}} {{values}} {{call-with-values}} 420 {{list-ref}} {{null?}} {{length}} {{not}} {{char?}} {{string?}} {{symbol?}} {{vector?}} {{pair?}} {{procedure?}} 421 {{boolean?}} {{number?}} {{complex?}} {{rational?}} {{real?}} {{exact?}} {{inexact?}} {{list?}} {{eof-object?}} 422 {{string-ref}} {{string-set!}} {{vector-ref}} {{vector-set!}} {{char=?}} {{char<?}} {{char>?}} {{char<=?}} {{char>=?}} 423 {{char-numeric?}} {{char-alphabetic?}} {{char-whitespace?}} {{char-upper-case?}} 424 {{char-lower-case?}} {{char-upcae}} {{char-downcase}} {{list-tail}} {{assv}} {{memv}} {{memq}} {{assoc}} 425 {{member}} {{set-car!}} {{set-cdr!}} {{abs}} {{exp}} {{sin}} {{cos}} {{tan}} {{log}} {{asin}} {{acos}} {{atan}} {{sqrt}} 426 {{zero?}} {{positive?}} {{negative?}} {{vector-length}} {{string-length}} {{char->integer}} 427 {{integer->char}} {{inexact->exact}} {{=}} {{>}} {{<}} {{>=}} {{<=}} {{for-each}} {{map}} {{substring}} 428 {{string-append}} {{gcd}} {{lcm}} {{list}} {{exact->inexact}} {{string->number}} {{number->string}} 429 {{even?}} {{odd?}} {{remainder}} {{floor}} {{ceiling}} {{truncate}} {{round}} {{cons}} {{vector}} {{string}} 430 {{string=?}} {{string-ci=?}} {{make-vector}} {{call-with-current-continuation}} 431 {{write-char}} {{read-string}} 453 432 454 433 The following extended bindings are handled specially: … … 551 530 When testing finalizers from the interpreter, you might want to define a trivial macro such as 552 531 553 (define-macro (v x) `(begin (print ,x) (void))) 532 (define-syntax v 533 (syntax-rules () 534 ((_ x) (begin (print x) (void))))) 554 535 555 536 and wrap calls to {{set-finalizer!}} in it. … … 563 544 564 545 <enscript highlight=scheme> 565 (require-extension readline)566 (current-input-port (make-gnu-readline-port))567 (gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history"))546 (require-extension readline) 547 (current-input-port (make-gnu-readline-port)) 548 (gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history")) 568 549 </enscript> 569 550 -
chicken/trunk/scripts/wiki2html.scm
r13709 r13710 18 18 19 19 (define +link+ 20 '(: #\[ #\[ (? (: (* space) "image:" (* space))) 20 '(: #\[ #\[ (submatch (* (~ #\] #\|))) (? #\| (submatch (* (~ #\])))) #\] #\])) 21 22 (define +image-link+ 23 '(: #\[ #\[ (* space) "image:" (* space) 21 24 (submatch (* (~ #\] #\|))) (? #\| (submatch (* (~ #\])))) #\] #\])) 22 25 23 26 (define +inline-element+ 24 `(or ,+code+ ,+ link+ ,+html-tag+ ,+bold+ ,+italic+))27 `(or ,+code+ ,+image-link+ ,+link+ ,+html-tag+ ,+bold+ ,+italic+)) 25 28 26 29 (define +http-url+ '(: (* space) "http://" (* any))) … … 169 172 (first m) 170 173 (continue m)))) 174 ((string-search (rx `(: bos ,+image-link+)) rest) => 175 (lambda (m) 176 (string-append 177 "<img src='" (clean (second m)) "' />" 178 (continue m)))) 171 179 ((string-search (rx `(: bos ,+link+)) rest) => 172 180 (lambda (m) … … 176 184 (string-search (rx '(: bos (* space) "tags:")) m1) ) 177 185 "") 178 (( member m1*manual-pages*)186 ((find (cut string-ci=? <> m1) *manual-pages*) 179 187 (string-append 180 188 "<a href='" (clean m1) ".html'>" (inline m1) "</a>"))
Note: See TracChangeset
for help on using the changeset viewer.