Updating additional docs to use backslash.

This commit is contained in:
Alex Shinn 2013-08-04 17:01:22 +09:00
parent 3212f52327
commit e136aa78e2
7 changed files with 167 additions and 167 deletions

View file

@ -31,19 +31,19 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; reading and writing ;; reading and writing
;; Display @var{str} to the given output port, defaulting to ;; Display \var{str} to the given output port, defaulting to
;; @scheme{(current-output-port)}, followed by a newline. ;; \scheme{(current-output-port)}, followed by a newline.
(define (write-line str . o) (define (write-line str . o)
(let ((out (if (pair? o) (car o) (current-output-port)))) (let ((out (if (pair? o) (car o) (current-output-port))))
(display str out) (display str out)
(newline out))) (newline out)))
;;> @subsubsubsection{(write-string str [out [start [end]]])} ;;> \subsubsubsection{(write-string str [out [start [end]]])}
;;> Writes the characters from @var{start} to @var{end} of string ;;> Writes the characters from \var{start} to \var{end} of string
;;> @var{str} to output port @var{out}, where @var{start} defaults ;;> \var{str} to output port \var{out}, where \var{start} defaults
;;> to 0 and @var{end} defaults to @scheme{(string-length @var{str})}. ;;> to 0 and \var{end} defaults to \scheme{(string-length \var{str})}.
(define (write-string str . o) (define (write-string str . o)
(let ((out (if (pair? o) (car o) (current-output-port))) (let ((out (if (pair? o) (car o) (current-output-port)))
@ -60,11 +60,11 @@
(display (substring str start end) out)))) (display (substring str start end) out))))
(display str out)))) (display str out))))
;;> @subsubsubsection{(read-line [in [n]])} ;;> \subsubsubsection{(read-line [in [n]])}
;;> Read a line from the input port @var{in}, defaulting to ;;> Read a line from the input port \var{in}, defaulting to
;;> @scheme{(current-input-port)}, and return the result as ;;> \scheme{(current-input-port)}, and return the result as
;;> a string not including the newline. Reads at most @var{n} ;;> a string not including the newline. Reads at most \var{n}
;;> characters, defaulting to 8192. ;;> characters, defaulting to 8192.
(cond-expand (cond-expand
@ -109,13 +109,13 @@
(else (else
res))))))) res)))))))
;;> @subsubsubsection{(read-string n [in])} ;;> \subsubsubsection{(read-string n [in])}
;;> Reads @var{n} characters from input-port @var{in}, ;;> Reads \var{n} characters from input-port \var{in},
;;> defaulting to @scheme{(current-input-port)}, and ;;> defaulting to \scheme{(current-input-port)}, and
;;> returns the result as a string. Returns @scheme{""} ;;> returns the result as a string. Returns \scheme{""}
;;> if @var{n} is zero. May return a string with fewer ;;> if \var{n} is zero. May return a string with fewer
;;> than @var{n} characters if the end of file is reached, ;;> than \var{n} characters if the end of file is reached,
;;> or the eof-object if no characters are available. ;;> or the eof-object if no characters are available.
(cond-expand (cond-expand
@ -140,14 +140,14 @@
(port-line in))) (port-line in)))
(cadr res))))))) (cadr res)))))))
;;> @subsubsubsection{(read-string! str n [in])} ;;> \subsubsubsection{(read-string! str n [in])}
;;> Reads @var{n} characters from port @var{in}, which ;;> Reads \var{n} characters from port \var{in}, which
;;> defaults to @scheme{(current-input-port)}, and writes ;;> defaults to \scheme{(current-input-port)}, and writes
;;> them into the string @var{str} starting at index 0. ;;> them into the string \var{str} starting at index 0.
;;> Returns the number of characters read. ;;> Returns the number of characters read.
;;> An error is signalled if the length of @var{str} is smaller ;;> An error is signalled if the length of \var{str} is smaller
;;> than @var{n}. ;;> than \var{n}.
(cond-expand (cond-expand
((not string-streams) ((not string-streams)

View file

@ -4,7 +4,7 @@
;; BSD-style license: http://synthcode.com/license.txt ;; BSD-style license: http://synthcode.com/license.txt
;;> The loop API is mostly compatible with Taylor Campbell's ;;> The loop API is mostly compatible with Taylor Campbell's
;;> @hyperlink["http://mumble.net/~campbell/scheme/foof-loop.txt"]{foof-loop}, ;;> \hyperlink["http://mumble.net/~campbell/scheme/foof-loop.txt"]{foof-loop},
;;> but the iterator API is different and subject to change. ;;> but the iterator API is different and subject to change.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -49,7 +49,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;> @subsubsubsection{@scheme{(loop [name] (vars ...) [=> result] body ...)}} ;;> \subsubsubsection{\scheme{(loop [name] (vars ...) [=> result] body ...)}}
(define-syntax loop (define-syntax loop
(syntax-rules () (syntax-rules ()
@ -124,27 +124,27 @@
. rest)))) . rest))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;> @subsubsection{Iterators} ;;> \subsubsection{Iterators}
;; Each gets passed two lists, those items left of the macro and those to ;; Each gets passed two lists, those items left of the macro and those to
;; the right, followed by a NEXT and REST continuation. ;; the right, followed by a NEXT and REST continuation.
;; ;;
;; Should finish with ;; Should finish with
;; ;;
;; @schemeblock{ ;; \schemeblock{
;; (next (outer-vars ...) (cursor-vars ...) (done?-tests ...) ;; (next (outer-vars ...) (cursor-vars ...) (done?-tests ...)
;; (loop-vars ...) (final-vars ...) . rest) ;; (loop-vars ...) (final-vars ...) . rest)
;; } ;; }
;; ;;
;; @itemlist[ ;; \itemlist[
;; @item{@var{outer-vars} - bound once outside the loop in a LET*} ;; \item{\var{outer-vars} - bound once outside the loop in a LET*}
;; @item{@var{cursor-vars} - DO-style bindings of the form (name init update)} ;; \item{\var{cursor-vars} - DO-style bindings of the form (name init update)}
;; @item{@var{done?-tests} - possibly empty list of forms that terminate the loop on #t} ;; \item{\var{done?-tests} - possibly empty list of forms that terminate the loop on #t}
;; @item{@var{loop-vars} - inner variables, updated in parallel after the cursors} ;; \item{\var{loop-vars} - inner variables, updated in parallel after the cursors}
;; @item{@var{final-vars} - final variables, bound only in the => result} ;; \item{\var{final-vars} - final variables, bound only in the => result}
;; ] ;; ]
;;> @subsubsubsection{@scheme{(for var [pair] (in-list ls [cdr]))}} ;;> \subsubsubsection{\scheme{(for var [pair] (in-list ls [cdr]))}}
;;> Basic list iterator. ;;> Basic list iterator.
@ -172,7 +172,7 @@
() ()
. rest)))) . rest))))
;;> @subsubsubsection{@scheme{(for elts [pairs] (in-lists lol [cdr [done?]]))}} ;;> \subsubsubsection{\scheme{(for elts [pairs] (in-lists lol [cdr [done?]]))}}
;;> Iterator from Taylor R. Campbell. If you know the number of lists ;;> Iterator from Taylor R. Campbell. If you know the number of lists
;;> ahead of time it's much more efficient to iterate over each one ;;> ahead of time it's much more efficient to iterate over each one
@ -215,12 +215,12 @@
(%in-idx < (lambda (x i) (- i 1)) (lambda (x) (- (length x) 1)) (lambda (x) 0) ref tmp seq next . rest)))) (%in-idx < (lambda (x i) (- i 1)) (lambda (x) (- (length x) 1)) (lambda (x) 0) ref tmp seq next . rest))))
)))) ))))
;;> @subsubsubsection{@scheme{(for var [index] (in-vector vec))}} ;;> \subsubsubsection{\scheme{(for var [index] (in-vector vec))}}
;;> @subsubsubsection{@scheme{(for var [index] (in-vector-reverse vec))}} ;;> \subsubsubsection{\scheme{(for var [index] (in-vector-reverse vec))}}
(define-in-indexed in-vector in-vector-reverse vector-length vector-ref) (define-in-indexed in-vector in-vector-reverse vector-length vector-ref)
;;> @subsubsubsection{@scheme{(for ch [cursor] (in-string str))}} ;;> \subsubsubsection{\scheme{(for ch [cursor] (in-string str))}}
(define-syntax in-string (define-syntax in-string
(syntax-rules () (syntax-rules ()
@ -229,7 +229,7 @@
string-cursor-start string-cursor-end string-cursor-ref string-cursor-start string-cursor-end string-cursor-ref
tmp s next . rest)))) tmp s next . rest))))
;;> @subsubsubsection{@scheme{(for ch [cursor] (in-string-reverse str))}} ;;> \subsubsubsection{\scheme{(for ch [cursor] (in-string-reverse str))}}
(define-syntax in-string-reverse (define-syntax in-string-reverse
(syntax-rules () (syntax-rules ()
@ -258,7 +258,7 @@
. rest)) . rest))
)) ))
;;> @subsubsubsection{@scheme{(for ch (in-port [input-port [reader [eof?]]]))}} ;;> \subsubsubsection{\scheme{(for ch (in-port [input-port [reader [eof?]]]))}}
(define-syntax in-port (define-syntax in-port
(syntax-rules () (syntax-rules ()
@ -278,7 +278,7 @@
() ()
. rest)))) . rest))))
;;> @subsubsubsection{@scheme{(for ch (in-file [input-port [reader [eof?]]]))}} ;;> \subsubsubsection{\scheme{(for ch (in-file [input-port [reader [eof?]]]))}}
(define-syntax in-file (define-syntax in-file
(syntax-rules () (syntax-rules ()
@ -296,7 +296,7 @@
((dummy (close-input-port p))) ((dummy (close-input-port p)))
. rest)))) . rest))))
;;> @subsubsubsection{@scheme{(for x (up-from [start] [(to limit)] [(by step)]))}} ;;> \subsubsubsection{\scheme{(for x (up-from [start] [(to limit)] [(by step)]))}}
(define-syntax up-from (define-syntax up-from
(syntax-rules (to by) (syntax-rules (to by)
@ -322,7 +322,7 @@
(next ((s start)) ((var s (+ var 1))) () () () . rest)) (next ((s start)) ((var s (+ var 1))) () () () . rest))
)) ))
;;> @subsubsubsection{@scheme{(for x (down-from [start] [(to limit)] [(by step)]))}} ;;> \subsubsubsection{\scheme{(for x (down-from [start] [(to limit)] [(by step)]))}}
(define-syntax down-from (define-syntax down-from
(syntax-rules (to by) (syntax-rules (to by)
@ -371,14 +371,14 @@
((var (final cursor))) ((var (final cursor)))
. rest)))) . rest))))
;;> @subsubsubsection{@scheme{(for x [pair] (listing expr))}} ;;> \subsubsubsection{\scheme{(for x [pair] (listing expr))}}
(define-syntax listing (define-syntax listing
(syntax-rules () (syntax-rules ()
((listing args next . rest) ((listing args next . rest)
(accumulating (cons reverse '()) args next . rest)))) (accumulating (cons reverse '()) args next . rest))))
;;> @subsubsubsection{@scheme{(for x [pair] (listing-reverse expr))}} ;;> \subsubsubsection{\scheme{(for x [pair] (listing-reverse expr))}}
(define-syntax listing-reverse (define-syntax listing-reverse
(syntax-rules () (syntax-rules ()
@ -388,28 +388,28 @@
(define (append-reverse rev tail) (define (append-reverse rev tail)
(if (null? rev) tail (append-reverse (cdr rev) (cons (car rev) tail)))) (if (null? rev) tail (append-reverse (cdr rev) (cons (car rev) tail))))
;;> @subsubsubsection{@scheme{(for x [pair] (appending expr))}} ;;> \subsubsubsection{\scheme{(for x [pair] (appending expr))}}
(define-syntax appending (define-syntax appending
(syntax-rules () (syntax-rules ()
((appending args next . rest) ((appending args next . rest)
(accumulating (append-reverse reverse '()) args next . rest)))) (accumulating (append-reverse reverse '()) args next . rest))))
;;> @subsubsubsection{@scheme{(for x [pair] (appending-reverse expr))}} ;;> \subsubsubsection{\scheme{(for x [pair] (appending-reverse expr))}}
(define-syntax appending-reverse (define-syntax appending-reverse
(syntax-rules () (syntax-rules ()
((appending-reverse args next . rest) ((appending-reverse args next . rest)
(accumulating (append-reverse (lambda (x) x) '()) args next . rest)))) (accumulating (append-reverse (lambda (x) x) '()) args next . rest))))
;;> @subsubsubsection{@scheme{(for x (summing expr))}} ;;> \subsubsubsection{\scheme{(for x (summing expr))}}
(define-syntax summing (define-syntax summing
(syntax-rules () (syntax-rules ()
((summing args next . rest) ((summing args next . rest)
(accumulating (+ (lambda (x) x) 0) args next . rest)))) (accumulating (+ (lambda (x) x) 0) args next . rest))))
;;> @subsubsubsection{@scheme{(for x (multiplying expr))}} ;;> \subsubsubsection{\scheme{(for x (multiplying expr))}}
(define-syntax multiplying (define-syntax multiplying
(syntax-rules () (syntax-rules ()

View file

@ -3,155 +3,155 @@
;; This code is written by Alex Shinn and placed in the ;; This code is written by Alex Shinn and placed in the
;; Public Domain. All warranties are disclaimed. ;; Public Domain. All warranties are disclaimed.
;;> @example-import[(srfi 9)] ;;> \example-import[(srfi 9)]
;;> This is a full superset of the popular @hyperlink[ ;;> This is a full superset of the popular \hyperlink[
;;> "http://www.cs.indiana.edu/scheme-repository/code.match.html"]{match} ;;> "http://www.cs.indiana.edu/scheme-repository/code.match.html"]{match}
;;> package by Andrew Wright, written in fully portable @scheme{syntax-rules} ;;> package by Andrew Wright, written in fully portable \scheme{syntax-rules}
;;> and thus preserving hygiene. ;;> and thus preserving hygiene.
;;> The most notable extensions are the ability to use @emph{non-linear} ;;> The most notable extensions are the ability to use \emph{non-linear}
;;> patterns - patterns in which the same identifier occurs multiple ;;> patterns - patterns in which the same identifier occurs multiple
;;> times, tail patterns after ellipsis, and the experimental tree patterns. ;;> times, tail patterns after ellipsis, and the experimental tree patterns.
;;> @subsubsection{Patterns} ;;> \subsubsection{Patterns}
;;> Patterns are written to look like the printed representation of ;;> Patterns are written to look like the printed representation of
;;> the objects they match. The basic usage is ;;> the objects they match. The basic usage is
;;> @scheme{(match expr (pat body ...) ...)} ;;> \scheme{(match expr (pat body ...) ...)}
;;> where the result of @var{expr} is matched against each pattern in ;;> where the result of \var{expr} is matched against each pattern in
;;> turn, and the corresponding body is evaluated for the first to ;;> turn, and the corresponding body is evaluated for the first to
;;> succeed. Thus, a list of three elements matches a list of three ;;> succeed. Thus, a list of three elements matches a list of three
;;> elements. ;;> elements.
;;> @example{(let ((ls (list 1 2 3))) (match ls ((1 2 3) #t)))} ;;> \example{(let ((ls (list 1 2 3))) (match ls ((1 2 3) #t)))}
;;> If no patterns match an error is signalled. ;;> If no patterns match an error is signalled.
;;> Identifiers will match anything, and make the corresponding ;;> Identifiers will match anything, and make the corresponding
;;> binding available in the body. ;;> binding available in the body.
;;> @example{(match (list 1 2 3) ((a b c) b))} ;;> \example{(match (list 1 2 3) ((a b c) b))}
;;> If the same identifier occurs multiple times, the first instance ;;> If the same identifier occurs multiple times, the first instance
;;> will match anything, but subsequent instances must match a value ;;> will match anything, but subsequent instances must match a value
;;> which is @scheme{equal?} to the first. ;;> which is \scheme{equal?} to the first.
;;> @example{(match (list 1 2 1) ((a a b) 1) ((a b a) 2))} ;;> \example{(match (list 1 2 1) ((a a b) 1) ((a b a) 2))}
;;> The special identifier @scheme{_} matches anything, no matter how ;;> The special identifier \scheme{_} matches anything, no matter how
;;> many times it is used, and does not bind the result in the body. ;;> many times it is used, and does not bind the result in the body.
;;> @example{(match (list 1 2 1) ((_ _ b) 1) ((a b a) 2))} ;;> \example{(match (list 1 2 1) ((_ _ b) 1) ((a b a) 2))}
;;> To match a literal identifier (or list or any other literal), use ;;> To match a literal identifier (or list or any other literal), use
;;> @scheme{quote}. ;;> \scheme{quote}.
;;> @example{(match 'a ('b 1) ('a 2))} ;;> \example{(match 'a ('b 1) ('a 2))}
;;> Analogous to its normal usage in scheme, @scheme{quasiquote} can ;;> Analogous to its normal usage in scheme, \scheme{quasiquote} can
;;> be used to quote a mostly literally matching object with selected ;;> be used to quote a mostly literally matching object with selected
;;> parts unquoted. ;;> parts unquoted.
;;> @example|{(match (list 1 2 3) (`(1 ,b ,c) (list b c)))}| ;;> \example|{(match (list 1 2 3) (`(1 ,b ,c) (list b c)))}|
;;> Often you want to match any number of a repeated pattern. Inside ;;> Often you want to match any number of a repeated pattern. Inside
;;> a list pattern you can append @scheme{...} after an element to ;;> a list pattern you can append \scheme{...} after an element to
;;> match zero or more of that pattern (like a regexp Kleene star). ;;> match zero or more of that pattern (like a regexp Kleene star).
;;> @example{(match (list 1 2) ((1 2 3 ...) #t))} ;;> \example{(match (list 1 2) ((1 2 3 ...) #t))}
;;> @example{(match (list 1 2 3) ((1 2 3 ...) #t))} ;;> \example{(match (list 1 2 3) ((1 2 3 ...) #t))}
;;> @example{(match (list 1 2 3 3 3) ((1 2 3 ...) #t))} ;;> \example{(match (list 1 2 3 3 3) ((1 2 3 ...) #t))}
;;> Pattern variables matched inside the repeated pattern are bound to ;;> Pattern variables matched inside the repeated pattern are bound to
;;> a list of each matching instance in the body. ;;> a list of each matching instance in the body.
;;> @example{(match (list 1 2) ((a b c ...) c))} ;;> \example{(match (list 1 2) ((a b c ...) c))}
;;> @example{(match (list 1 2 3) ((a b c ...) c))} ;;> \example{(match (list 1 2 3) ((a b c ...) c))}
;;> @example{(match (list 1 2 3 4 5) ((a b c ...) c))} ;;> \example{(match (list 1 2 3 4 5) ((a b c ...) c))}
;;> More than one @scheme{...} may not be used in the same list, since ;;> More than one \scheme{...} may not be used in the same list, since
;;> this would require exponential backtracking in the general case. ;;> this would require exponential backtracking in the general case.
;;> However, @scheme{...} need not be the final element in the list, ;;> However, \scheme{...} need not be the final element in the list,
;;> and may be succeeded by a fixed number of patterns. ;;> and may be succeeded by a fixed number of patterns.
;;> @example{(match (list 1 2 3 4) ((a b c ... d e) c))} ;;> \example{(match (list 1 2 3 4) ((a b c ... d e) c))}
;;> @example{(match (list 1 2 3 4 5) ((a b c ... d e) c))} ;;> \example{(match (list 1 2 3 4 5) ((a b c ... d e) c))}
;;> @example{(match (list 1 2 3 4 5 6 7) ((a b c ... d e) c))} ;;> \example{(match (list 1 2 3 4 5 6 7) ((a b c ... d e) c))}
;;> @scheme{___} is provided as an alias for @scheme{...} when it is ;;> \scheme{___} is provided as an alias for \scheme{...} when it is
;;> inconvenient to use the ellipsis (as in a syntax-rules template). ;;> inconvenient to use the ellipsis (as in a syntax-rules template).
;;> The @scheme{..1} syntax is exactly like the @scheme{...} except ;;> The \scheme{..1} syntax is exactly like the \scheme{...} except
;;> that it matches one or more repetitions (like a regexp "+"). ;;> that it matches one or more repetitions (like a regexp "+").
;;> @example{(match (list 1 2) ((a b c ..1) c))} ;;> \example{(match (list 1 2) ((a b c ..1) c))}
;;> @example{(match (list 1 2 3) ((a b c ..1) c))} ;;> \example{(match (list 1 2 3) ((a b c ..1) c))}
;;> The boolean operators @scheme{and}, @scheme{or} and @scheme{not} ;;> The boolean operators \scheme{and}, \scheme{or} and \scheme{not}
;;> can be used to group and negate patterns analogously to their ;;> can be used to group and negate patterns analogously to their
;;> Scheme counterparts. ;;> Scheme counterparts.
;;> The @scheme{and} operator ensures that all subpatterns match. ;;> The \scheme{and} operator ensures that all subpatterns match.
;;> This operator is often used with the idiom @scheme{(and x pat)} to ;;> This operator is often used with the idiom \scheme{(and x pat)} to
;;> bind @var{x} to the entire value that matches @var{pat} ;;> bind \var{x} to the entire value that matches \var{pat}
;;> (c.f. "as-patterns" in ML or Haskell). Another common use is in ;;> (c.f. "as-patterns" in ML or Haskell). Another common use is in
;;> conjunction with @scheme{not} patterns to match a general case ;;> conjunction with \scheme{not} patterns to match a general case
;;> with certain exceptions. ;;> with certain exceptions.
;;> @example{(match 1 ((and) #t))} ;;> \example{(match 1 ((and) #t))}
;;> @example{(match 1 ((and x) x))} ;;> \example{(match 1 ((and x) x))}
;;> @example{(match 1 ((and x 1) x))} ;;> \example{(match 1 ((and x 1) x))}
;;> The @scheme{or} operator ensures that at least one subpattern ;;> The \scheme{or} operator ensures that at least one subpattern
;;> matches. If the same identifier occurs in different subpatterns, ;;> matches. If the same identifier occurs in different subpatterns,
;;> it is matched independently. All identifiers from all subpatterns ;;> it is matched independently. All identifiers from all subpatterns
;;> are bound if the @scheme{or} operator matches, but the binding is ;;> are bound if the \scheme{or} operator matches, but the binding is
;;> only defined for identifiers from the subpattern which matched. ;;> only defined for identifiers from the subpattern which matched.
;;> @example{(match 1 ((or) #t) (else #f))} ;;> \example{(match 1 ((or) #t) (else #f))}
;;> @example{(match 1 ((or x) x))} ;;> \example{(match 1 ((or x) x))}
;;> @example{(match 1 ((or x 2) x))} ;;> \example{(match 1 ((or x 2) x))}
;;> The @scheme{not} operator succeeds if the given pattern doesn't ;;> The \scheme{not} operator succeeds if the given pattern doesn't
;;> match. None of the identifiers used are available in the body. ;;> match. None of the identifiers used are available in the body.
;;> @example{(match 1 ((not 2) #t))} ;;> \example{(match 1 ((not 2) #t))}
;;> The more general operator @scheme{?} can be used to provide a ;;> The more general operator \scheme{?} can be used to provide a
;;> predicate. The usage is @scheme{(? predicate pat ...)} where ;;> predicate. The usage is \scheme{(? predicate pat ...)} where
;;> @var{predicate} is a Scheme expression evaluating to a predicate ;;> \var{predicate} is a Scheme expression evaluating to a predicate
;;> called on the value to match, and any optional patterns after the ;;> called on the value to match, and any optional patterns after the
;;> predicate are then matched as in an @scheme{and} pattern. ;;> predicate are then matched as in an \scheme{and} pattern.
;;> @example{(match 1 ((? odd? x) x))} ;;> \example{(match 1 ((? odd? x) x))}
;;> The field operator @scheme{=} is used to extract an arbitrary ;;> The field operator \scheme{=} is used to extract an arbitrary
;;> field and match against it. It is useful for more complex or ;;> field and match against it. It is useful for more complex or
;;> conditional destructuring that can't be more directly expressed in ;;> conditional destructuring that can't be more directly expressed in
;;> the pattern syntax. The usage is @scheme{(= field pat)}, where ;;> the pattern syntax. The usage is \scheme{(= field pat)}, where
;;> @var{field} can be any expression, and should result in a ;;> \var{field} can be any expression, and should result in a
;;> procedure of one argument, which is applied to the value to match ;;> procedure of one argument, which is applied to the value to match
;;> to generate a new value to match against @var{pat}. ;;> to generate a new value to match against \var{pat}.
;;> Thus the pattern @scheme{(and (= car x) (= cdr y))} is equivalent ;;> Thus the pattern \scheme{(and (= car x) (= cdr y))} is equivalent
;;> to @scheme{(x . y)}, except it will result in an immediate error ;;> to \scheme{(x . y)}, except it will result in an immediate error
;;> if the value isn't a pair. ;;> if the value isn't a pair.
;;> @example{(match '(1 . 2) ((= car x) x))} ;;> \example{(match '(1 . 2) ((= car x) x))}
;;> @example{(match 4 ((= square x) x))} ;;> \example{(match 4 ((= square x) x))}
;;> The record operator @scheme{$} is used as a concise way to match ;;> The record operator \scheme{$} is used as a concise way to match
;;> records defined by SRFI-9 (or SRFI-99). The usage is ;;> records defined by SRFI-9 (or SRFI-99). The usage is
;;> @scheme{($ rtd field ...)}, where @var{rtd} should be the record ;;> \scheme{($ rtd field ...)}, where \var{rtd} should be the record
;;> type descriptor specified as the first argument to ;;> type descriptor specified as the first argument to
;;> @scheme{define-record-type}, and each @var{field} is a subpattern ;;> \scheme{define-record-type}, and each \var{field} is a subpattern
;;> matched against the fields of the record in order. Not all fields ;;> matched against the fields of the record in order. Not all fields
;;> must be present. ;;> must be present.
;;> @example{ ;;> \example{
;;> (let () ;;> (let ()
;;> (define-record-type employee ;;> (define-record-type employee
;;> (make-employee name title) ;;> (make-employee name title)
@ -162,29 +162,29 @@
;;> (($ employee n t) (list t n)))) ;;> (($ employee n t) (list t n))))
;;> } ;;> }
;;> The @scheme{set!} and @scheme{get!} operators are used to bind an ;;> The \scheme{set!} and \scheme{get!} operators are used to bind an
;;> identifier to the setter and getter of a field, respectively. The ;;> identifier to the setter and getter of a field, respectively. The
;;> setter is a procedure of one argument, which mutates the field to ;;> setter is a procedure of one argument, which mutates the field to
;;> that argument. The getter is a procedure of no arguments which ;;> that argument. The getter is a procedure of no arguments which
;;> returns the current value of the field. ;;> returns the current value of the field.
;;> @example{(let ((x (cons 1 2))) (match x ((1 . (set! s)) (s 3) x)))} ;;> \example{(let ((x (cons 1 2))) (match x ((1 . (set! s)) (s 3) x)))}
;;> @example{(match '(1 . 2) ((1 . (get! g)) (g)))} ;;> \example{(match '(1 . 2) ((1 . (get! g)) (g)))}
;;> The new operator @scheme{***} can be used to search a tree for ;;> The new operator \scheme{***} can be used to search a tree for
;;> subpatterns. A pattern of the form @scheme{(x *** y)} represents ;;> subpatterns. A pattern of the form \scheme{(x *** y)} represents
;;> the subpattern @var{y} located somewhere in a tree where the path ;;> the subpattern \var{y} located somewhere in a tree where the path
;;> from the current object to @var{y} can be seen as a list of the ;;> from the current object to \var{y} can be seen as a list of the
;;> form @scheme{(x ...)}. @var{y} can immediately match the current ;;> form \scheme{(x ...)}. \var{y} can immediately match the current
;;> object in which case the path is the empty list. In a sense it's ;;> object in which case the path is the empty list. In a sense it's
;;> a 2-dimensional version of the @scheme{...} pattern. ;;> a 2-dimensional version of the \scheme{...} pattern.
;;> As a common case the pattern @scheme{(_ *** y)} can be used to ;;> As a common case the pattern \scheme{(_ *** y)} can be used to
;;> search for @var{y} anywhere in a tree, regardless of the path ;;> search for \var{y} anywhere in a tree, regardless of the path
;;> used. ;;> used.
;;> @example{(match '(a (a (a b))) ((x *** 'b) x))} ;;> \example{(match '(a (a (a b))) ((x *** 'b) x))}
;;> @example{(match '(a (b) (c (d e) (f g))) ((x *** 'g) x))} ;;> \example{(match '(a (b) (c (d e) (f g))) ((x *** 'g) x))}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Notes ;; Notes
@ -239,19 +239,19 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;> @subsubsection{Syntax} ;;> \subsubsection{Syntax}
;;> @subsubsubsection{@rawcode{(match expr (pattern . body) ...)@br{} ;;> \subsubsubsection{\rawcode{(match expr (pattern . body) ...)\br{}
;;> (match expr (pattern (=> failure) . body) ...)}} ;;> (match expr (pattern (=> failure) . body) ...)}}
;;> The result of @var{expr} is matched against each @var{pattern} in ;;> The result of \var{expr} is matched against each \var{pattern} in
;;> turn, according to the pattern rules described in the previous ;;> turn, according to the pattern rules described in the previous
;;> section, until the the first @var{pattern} matches. When a match is ;;> section, until the the first \var{pattern} matches. When a match is
;;> found, the corresponding @var{body}s are evaluated in order, ;;> found, the corresponding \var{body}s are evaluated in order,
;;> and the result of the last expression is returned as the result ;;> and the result of the last expression is returned as the result
;;> of the entire @scheme{match}. If a @var{failure} is provided, ;;> of the entire \scheme{match}. If a \var{failure} is provided,
;;> then it is bound to a procedure of no arguments which continues, ;;> then it is bound to a procedure of no arguments which continues,
;;> processing at the next @var{pattern}. If no @var{pattern} matches, ;;> processing at the next \var{pattern}. If no \var{pattern} matches,
;;> an error is signalled. ;;> an error is signalled.
;; The basic interface. MATCH just performs some basic syntax ;; The basic interface. MATCH just performs some basic syntax
@ -783,7 +783,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Gimme some sugar baby. ;; Gimme some sugar baby.
;;> Shortcut for @scheme{lambda} + @scheme{match}. Creates a ;;> Shortcut for \scheme{lambda} + \scheme{match}. Creates a
;;> procedure of one argument, and matches that argument against each ;;> procedure of one argument, and matches that argument against each
;;> clause. ;;> clause.
@ -791,7 +791,7 @@
(syntax-rules () (syntax-rules ()
((_ (pattern . body) ...) (lambda (expr) (match expr (pattern . body) ...))))) ((_ (pattern . body) ...) (lambda (expr) (match expr (pattern . body) ...)))))
;;> Similar to @scheme{match-lambda}. Creates a procedure of any ;;> Similar to \scheme{match-lambda}. Creates a procedure of any
;;> number of arguments, and matches the argument list against each ;;> number of arguments, and matches the argument list against each
;;> clause. ;;> clause.
@ -803,7 +803,7 @@
;;> the body with all match variables in scope. Raises an error if ;;> the body with all match variables in scope. Raises an error if
;;> any of the expressions fail to match. Syntax analogous to named ;;> any of the expressions fail to match. Syntax analogous to named
;;> let can also be used for recursive functions which match on their ;;> let can also be used for recursive functions which match on their
;;> arguments as in @scheme{match-lambda*}. ;;> arguments as in \scheme{match-lambda*}.
(define-syntax match-let (define-syntax match-let
(syntax-rules () (syntax-rules ()
@ -812,7 +812,7 @@
((_ loop ((var init) ...) . body) ((_ loop ((var init) ...) . body)
(match-named-let loop ((var init) ...) . body)))) (match-named-let loop ((var init) ...) . body))))
;;> Similar to @scheme{match-let}, but analogously to @scheme{letrec} ;;> Similar to \scheme{match-let}, but analogously to \scheme{letrec}
;;> matches and binds the variables with all match variables in scope. ;;> matches and binds the variables with all match variables in scope.
(define-syntax match-letrec (define-syntax match-letrec
@ -846,9 +846,9 @@
((_ loop (v ...) ((pat expr) . rest) . body) ((_ loop (v ...) ((pat expr) . rest) . body)
(match-named-let loop (v ... (pat expr tmp)) rest . body)))) (match-named-let loop (v ... (pat expr tmp)) rest . body))))
;;> @subsubsubsection{@rawcode{(match-let* ((var value) ...) body ...)}} ;;> \subsubsubsection{\rawcode{(match-let* ((var value) ...) body ...)}}
;;> Similar to @scheme{match-let}, but analogously to @scheme{let*} ;;> Similar to \scheme{match-let}, but analogously to \scheme{let*}
;;> matches and binds the variables in sequence, with preceding match ;;> matches and binds the variables in sequence, with preceding match
;;> variables in scope. ;;> variables in scope.

View file

@ -44,12 +44,12 @@
(c-include "signal.c") (c-include "signal.c")
;;> @subsubsubsection{@rawcode{(set-signal-action! signal handler)}} ;;> \subsubsubsection{\rawcode{(set-signal-action! signal handler)}}
;;> Sets the signal handler for @var{signal} to @var{handler} ;;> Sets the signal handler for \var{signal} to \var{handler}
;;> and returns the old handler. @var{handler} should be a procedure ;;> and returns the old handler. \var{handler} should be a procedure
;;> of one argument, the signal number, the value @scheme{#t} for ;;> of one argument, the signal number, the value \scheme{#t} for
;;> the default signal handler, or @scheme{#f} for no handler. ;;> the default signal handler, or \scheme{#f} for no handler.
;;> Signal handlers are queued run in a dedicated thread after the ;;> Signal handlers are queued run in a dedicated thread after the
;;> system handler has returned. ;;> system handler has returned.
@ -77,19 +77,19 @@
(define-c errno (current-signal-mask "sigprocmask") (define-c errno (current-signal-mask "sigprocmask")
((value SIG_BLOCK int) (pointer value NULL sigset_t) (pointer result sigset_t))) ((value SIG_BLOCK int) (pointer value NULL sigset_t) (pointer result sigset_t)))
;;> Send a @var{signal/alarm} signal to the current process ;;> Send a \var{signal/alarm} signal to the current process
;;> after @var{unsigned-int} seconds have elapsed. ;;> after \var{unsigned-int} seconds have elapsed.
(define-c unsigned-int alarm (unsigned-int)) (define-c unsigned-int alarm (unsigned-int))
;;> Suspend the current process for @var{unsigned-int} seconds. ;;> Suspend the current process for \var{unsigned-int} seconds.
;;> See @hyperlink["http://srfi.schemers.org/srfi-18/srfi-18.html"]{SRFI-18} ;;> See \hyperlink["http://srfi.schemers.org/srfi-18/srfi-18.html"]{SRFI-18}
;;> @scheme{thread-sleep!} for a light-weight sleep for only the ;;> \scheme{thread-sleep!} for a light-weight sleep for only the
;;> current thread. ;;> current thread.
(define-c unsigned-int sleep (unsigned-int)) (define-c unsigned-int sleep (unsigned-int))
;;> Fork the current process. Returns @rawcode{0} for the newly ;;> Fork the current process. Returns \rawcode{0} for the newly
;;> created process, and the process id of the new process for ;;> created process, and the process id of the new process for
;;> the parent. ;;> the parent.
@ -99,12 +99,12 @@
;;(define-c pid_t wait ((result int))) ;;(define-c pid_t wait ((result int)))
;;> @subsubsubsection{@rawcode{(waitpid pid options)}} ;;> \subsubsubsection{\rawcode{(waitpid pid options)}}
;;> Wait on the process @var{pid}, or any child process if @var{pid} ;;> Wait on the process \var{pid}, or any child process if \var{pid}
;;> is @rawcode{-1}. @var{options} should be 0, or @var{wait/no-hang} ;;> is \rawcode{-1}. \var{options} should be 0, or \var{wait/no-hang}
;;> to return immediately if no processes have reported status. Returns ;;> to return immediately if no processes have reported status. Returns
;;> a list whose first element is the actual @var{pid} reporting, and ;;> a list whose first element is the actual \var{pid} reporting, and
;;> the second element is the integer status. ;;> the second element is the integer status.
(define-c pid_t waitpid (int (result int) int)) (define-c pid_t waitpid (int (result int) int))

View file

@ -3,9 +3,9 @@
(c-system-include "pwd.h") (c-system-include "pwd.h")
(c-system-include "sys/types.h") (c-system-include "sys/types.h")
;;> @subsubsubsection{@scheme{(user-information name-or-id)}} ;;> \subsubsubsection{\scheme{(user-information name-or-id)}}
;;> Returns the password entry for the given user. @var{name-or-id} ;;> Returns the password entry for the given user. \var{name-or-id}
;;> should be a string indicating the user name, or an integer ;;> should be a string indicating the user name, or an integer
;;> for the user id. ;;> for the user id.
@ -20,7 +20,7 @@
(string pw_shell user-shell)) (string pw_shell user-shell))
;;> Accessors for the password entry structure returned by ;;> Accessors for the password entry structure returned by
;;> @scheme{user-information}. ;;> \scheme{user-information}.
;;/ ;;/
(define-c uid_t (current-user-id "getuid") ()) (define-c uid_t (current-user-id "getuid") ())
@ -45,7 +45,7 @@
(define-c pid_t (create-session "setsid") ()) (define-c pid_t (create-session "setsid") ())
;;> Set @var{string} to be the new root directory, so that ;;> Set \var{string} to be the new root directory, so that
;;> paths beginning with "/" are resolved relative to the ;;> paths beginning with "/" are resolved relative to the
;;> new root. ;;> new root.

View file

@ -17,7 +17,7 @@
(int tm_yday time-day-of-year) (int tm_yday time-day-of-year)
(int tm_isdst time-dst?)) (int tm_isdst time-dst?))
;;> Accessors for the @scheme{tm} struct. ;;> Accessors for the \scheme{tm} struct.
;;/ ;;/
(define-c-struct timeval (define-c-struct timeval
@ -26,7 +26,7 @@
(time_t tv_sec timeval-seconds) (time_t tv_sec timeval-seconds)
(int tv_usec timeval-microseconds)) (int tv_usec timeval-microseconds))
;;> Accessors for the @scheme{timeval} struct. ;;> Accessors for the \scheme{timeval} struct.
;;/ ;;/
(define-c-struct timezone (define-c-struct timezone
@ -34,7 +34,7 @@
(int tz_minuteswest timezone-offset) (int tz_minuteswest timezone-offset)
(int tz_dsttime timezone-dst-time)) (int tz_dsttime timezone-dst-time))
;;> Accessors for the @scheme{timezone} struct. ;;> Accessors for the \scheme{timezone} struct.
;;/ ;;/
;;> Returns the current time as an integer number ;;> Returns the current time as an integer number

View file

@ -1,14 +1,14 @@
;;> @subsubsubsection{(trace proc)} ;;> \subsubsubsection{(trace proc)}
;;> Write a trace of all calls to the procedure @var{proc} to ;;> Write a trace of all calls to the procedure \var{proc} to
;;> @scheme{(current-error-port)}. ;;> \scheme{(current-error-port)}.
;;> @subsubsubsection{(untrace proc)} ;;> \subsubsubsection{(untrace proc)}
;;> Remove any active traces on the procedure @var{proc}. ;;> Remove any active traces on the procedure \var{proc}.
;;> @subsubsubsection{(untrace-all)} ;;> \subsubsubsection{(untrace-all)}
;;> Remove all active procedure traces. ;;> Remove all active procedure traces.