Changeset 13710 in project for chicken


Ignore:
Timestamp:
03/12/09 13:11:25 (11 years ago)
Author:
felix winkelmann
Message:

more cleaning up in manual

Location:
chicken/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/manual/Accessing external objects

    r13683 r13710  
    8686even have to specify an lvalue.
    8787
    88 <enscript highlight=scheme>
    89 #>
    90 enum { abc=3, def, ghi };
    91 <#
    92 
    93 (define-macro (define-simple-foreign-enum . items)
    94   `(begin
    95      ,@(map (match-lambda
    96               [(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                               ==> 5
    103 </enscript>
    104 
    10588
    10689=== foreign-lambda
  • chicken/trunk/manual/Bugs and limitations

    r13709 r13710  
    1414Previous: [[Data representation]]
    1515
    16 Next: [[faq]]
     16Next: [[FAQ]]
  • chicken/trunk/manual/The User's Manual

    r13683 r13710  
    11[[tags:manual]]
    22
    3 == The User's Manual
     3[[image:http://www.call-with-current-continuation.org/chicken.png]]
     4
     5== The CHICKEN User's Manual
    46
    57This is the user's manual for the Chicken Scheme compiler, version 4.0.0x5
  • chicken/trunk/manual/Unit eval

    r13683 r13710  
    109109changes the current exception-handler to display a message, write
    110110any arguments to the value of {{(current-error-port)}} and reset.
    111 
    112 
    113 === Macros
    114 
    115 ==== get-line-number
    116 
    117  [procedure] (get-line-number EXPR)
    118 
    119 If {{EXPR}} is a pair with the car being a symbol, and line-number
    120 information is available for this expression, then this procedure returns
    121 the associated line number. If line-number information is not available,
    122 then {{#f}} is returned.  Note that line-number information for
    123 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 ==== expand
    132 
    133  [procedure] (expand X)
    134 
    135 If {{X}} is a macro-form, expand the macro (and repeat expansion
    136 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-error
    145 
    146  [procedure] (syntax-error [LOCATION] MESSAGE ARGUMENT ...)
    147 
    148 Signals an exception of the kind {{(exn syntax)}}. Otherwise identical to
    149 {{error}}.
    150111
    151112
  • chicken/trunk/manual/Unit expand

    r13686 r13710  
    44== Unit expand
    55
    6 This unit has support for macro- and module handling. This unit is used
     6This unit has support for syntax- and module handling. This unit is used
    77by default, unless the program is compiled with the {{-explicit-use}}
    88option.
     
    2020expressions is only available in the compiler.
    2121
    22 ==== macro?
    23 
    24  [procedure] (macro? SYMBOL)
    25 
    26 Returns {{#t}} if there exists a macro-definition for {{SYMBOL}}.
    27 
    2822==== expand
    2923
     
    3226If {{X}} is a macro-form, expand the macro (and repeat expansion
    3327until 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}}.
    4028
    4129==== syntax-error
  • chicken/trunk/manual/Unit library

    r13709 r13710  
    8080
    8181{{most-positive-fixnum}}
     82
    8283{{most-negative-fixnum}}
     84
    8385{{fixnum-bits}}
     86
    8487{{fixnum-precision}}
    8588
  • chicken/trunk/manual/faq

    r13709 r13710  
    226226
    227227<enscript highlight=scheme>
    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) ) ) ) )
     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) ) ) ) )
    241241</enscript>
    242242
     
    264264
    265265It 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 exception
    270 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}} special
    272 form.
    273266
    274267=== Warnings and errors
     
    305298declarations) and use this feature only if the application works properly.
    306299
    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 running
    311 code). To speed up macro-expansion time, the compiler and the interpreter both already provide the compiled
    312 {{match-...}} macro definitions. Macros shadowed lexically are no problem, but global definitions
    313 of variables named identically to (global) macros are useless - the macro definition shadows the global
    314 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>
    321300==== Why don't toplevel-continuations captured in interpreted code work?
    322301
     
    342321
    343322<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))
    347326</enscript>
    348327
     
    352331
    353332<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))
    363342</enscript>
    364343
     
    368347
    369348<enscript highlight=scheme>
    370 #;1> (use srfi-18)
    371 ; loading library srfi-18 ...
    372 Error: (load-library) unable to load library
    373 srfi-18
    374 "dlopen(libchicken.dylib, 9): image not found"                ;; on a Mac
    375 "libchicken.so: cannot open shared object file: No such file or directory"  ;; Linux
     349 #;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
    376355</enscript>
    377356
     
    438417and compiler settings:
    439418
    440  {{+}} {{*}} {{-}} {{/}} {{quotient}} {{eq?}} {{eqv?}} {{equal?}} {{apply}} {{c...r}} {{values}} {{call-with-values}}
    441  {{list-ref}} {{null?}} {{length}} {{not}} {{char?}} {{string?}} {{symbol?}} {{vector?}} {{pair?}} {{procedure?}}
    442  {{boolean?}} {{number?}} {{complex?}} {{rational?}} {{real?}} {{exact?}} {{inexact?}} {{list?}} {{eof-object?}}
    443  {{string-ref}} {{string-set!}} {{vector-ref}} {{vector-set!}} {{char=?}} {{char<?}} {{char>?}} {{char<=?}} {{char>=?}}
    444  {{char-numeric?}} {{char-alphabetic?}} {{char-whitespace?}} {{char-upper-case?}}
    445  {{char-lower-case?}} {{char-upcae}} {{char-downcase}} {{list-tail}} {{assv}} {{memv}} {{memq}} {{assoc}}
    446  {{member}} {{set-car!}} {{set-cdr!}} {{abs}} {{exp}} {{sin}} {{cos}} {{tan}} {{log}} {{asin}} {{acos}} {{atan}} {{sqrt}}
    447  {{zero?}} {{positive?}} {{negative?}} {{vector-length}} {{string-length}} {{char->integer}}
    448  {{integer->char}} {{inexact->exact}} {{=}} {{>}} {{<}} {{>=}} {{<=}} {{for-each}} {{map}} {{substring}}
    449  {{string-append}} {{gcd}} {{lcm}} {{list}} {{exact->inexact}} {{string->number}} {{number->string}}
    450  {{even?}} {{odd?}} {{remainder}} {{floor}} {{ceiling}} {{truncate}} {{round}} {{cons}} {{vector}} {{string}}
    451  {{string=?}} {{string-ci=?}} {{make-vector}} {{call-with-current-continuation}}
    452  {{write-char}} {{read-string}}
     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}}
    453432
    454433The following extended bindings are handled specially:
     
    551530When testing finalizers from the interpreter, you might want to define a trivial macro such as
    552531
    553  (define-macro (v x) `(begin (print ,x) (void)))
     532 (define-syntax v
     533   (syntax-rules ()
     534     ((_ x) (begin (print x) (void)))))
    554535
    555536and wrap calls to {{set-finalizer!}} in it.
     
    563544
    564545<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"))
    568549</enscript>
    569550
  • chicken/trunk/scripts/wiki2html.scm

    r13709 r13710  
    1818
    1919(define +link+
    20   '(: #\[ #\[ (? (: (* space) "image:" (* space)))
     20  '(: #\[ #\[ (submatch (* (~ #\] #\|))) (? #\| (submatch (* (~ #\])))) #\] #\]))
     21
     22(define +image-link+
     23  '(: #\[ #\[ (* space) "image:" (* space)
    2124      (submatch (* (~ #\] #\|))) (? #\| (submatch (* (~ #\])))) #\] #\]))
    2225
    2326(define +inline-element+
    24   `(or ,+code+ ,+link+ ,+html-tag+ ,+bold+ ,+italic+))
     27  `(or ,+code+ ,+image-link+ ,+link+ ,+html-tag+ ,+bold+ ,+italic+))
    2528
    2629(define +http-url+ '(: (* space) "http://" (* any)))
     
    169172                     (first m)
    170173                     (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))))
    171179                 ((string-search (rx `(: bos ,+link+)) rest) =>
    172180                  (lambda (m)
     
    176184                                  (string-search (rx '(: bos (* space) "tags:")) m1) )
    177185                              "")
    178                              ((member m1 *manual-pages*)
     186                             ((find (cut string-ci=? <> m1) *manual-pages*)
    179187                              (string-append
    180188                               "<a href='" (clean m1) ".html'>" (inline m1) "</a>"))
Note: See TracChangeset for help on using the changeset viewer.