add in-lines and some doc clarifications
svn: r9072
This commit is contained in:
parent
2be39925e3
commit
c81eb6ede0
|
@ -30,6 +30,7 @@
|
|||
(rename *in-bytes in-bytes)
|
||||
in-input-port-bytes
|
||||
in-input-port-chars
|
||||
in-lines
|
||||
in-hash-table
|
||||
in-hash-table-keys
|
||||
in-hash-table-values
|
||||
|
@ -431,6 +432,22 @@
|
|||
(lambda (x) (not (eof-object? x)))
|
||||
(lambda (x v) #t)))))
|
||||
|
||||
(define in-lines
|
||||
(case-lambda
|
||||
[() (in-lines (current-input-port))]
|
||||
[(v) (in-lines v 'any)]
|
||||
[(v mode)
|
||||
(unless (input-port? v) (raise-type-error 'in-lines "input-port" v))
|
||||
(unless (memq mode '(linefeed return return-linefeed any any-one))
|
||||
(raise-type-error 'in-lines "'linefeed, 'return, 'return-linefeed, 'any, or 'any-one)" mode))
|
||||
(make-do-sequence (lambda ()
|
||||
(values (lambda (v) (read-line v mode))
|
||||
(lambda (v) v)
|
||||
v
|
||||
(lambda (v) #t)
|
||||
(lambda (x) (not (eof-object? x)))
|
||||
(lambda (x v) #t))))]))
|
||||
|
||||
(define (in-hash-table ht)
|
||||
(unless (hash-table? ht) (raise-type-error 'in-hash-table "hash-table" ht))
|
||||
(make-do-sequence (lambda () (:hash-table-gen ht cons (lambda (p) (values (car p) (cdr p)))))))
|
||||
|
|
|
@ -89,12 +89,21 @@ Returns a sequence equivalent to @scheme[str].
|
|||
Returns a sequence equivalent to @scheme[bstr].
|
||||
@speed[in-bytes "byte string"]}
|
||||
|
||||
@defproc[(in-input-port-bytes [inp input-port?]) sequence?]{
|
||||
Returns a sequence equivalent to @scheme[inp].}
|
||||
@defproc[(in-input-port-bytes [in input-port?]) sequence?]{
|
||||
Returns a sequence equivalent to @scheme[in].}
|
||||
|
||||
@defproc[(in-input-port-chars [inp input-port?]) sequence?]{ Returns a
|
||||
sequence whose elements are read as characters form @scheme[inp] (as
|
||||
opposed to using @scheme[inp] directly as a sequence to get bytes).}
|
||||
@defproc[(in-input-port-chars [in input-port?]) sequence?]{ Returns a
|
||||
sequence whose elements are read as characters form @scheme[in] (as
|
||||
opposed to using @scheme[in] directly as a sequence to get bytes).}
|
||||
|
||||
@defproc[(in-lines [in input-port? (current-input-port)]
|
||||
[mode (one-of 'linefeed 'return 'return-linefeed 'any 'any-one) 'any])
|
||||
sequence?]{
|
||||
|
||||
Returns a sequence whose elements are the result of @scheme[(read-line
|
||||
in mode)] until an end-of-line is encountered. Note that the default
|
||||
mode is @scheme['any], whereas the default mode of @scheme[read-line]
|
||||
is @scheme['linefeed].}
|
||||
|
||||
@defproc[(in-hash-table [ht hash-table?]) sequence?]{
|
||||
Returns a sequence equivalent to @scheme[ht].}
|
||||
|
@ -153,8 +162,7 @@ The @scheme[thunk] results define the generated elements as follows:
|
|||
@itemize{
|
||||
|
||||
@item{The first result is a @scheme[_pos->element] procedure that takes
|
||||
the current position and returns the value(s) for the current element.
|
||||
It is called only once per position.}
|
||||
the current position and returns the value(s) for the current element.}
|
||||
|
||||
@item{The second result is a @scheme[_next-pos] procedure that takes
|
||||
the current position and returns the next position.}
|
||||
|
@ -176,7 +184,11 @@ The @scheme[thunk] results define the generated elements as follows:
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
Each of the procedures listed above is called only once per position.
|
||||
Among the last three procedures, as soon as one of the procedures
|
||||
returns @scheme[#f], the sequence ends, and none are call
|
||||
again. Typically, one of the functions determines the end condition,
|
||||
and the other two functions always return @scheme[#t].}
|
||||
|
||||
@section{Sequence Generators}
|
||||
|
||||
|
|
|
@ -1037,6 +1037,13 @@ static Scheme_Object *_dynamic_require(int argc, Scheme_Object *argv[],
|
|||
errname,
|
||||
name, srcm->modname);
|
||||
}
|
||||
|
||||
if (!menv || !menv->toplevel) {
|
||||
scheme_raise_exn(MZEXN_FAIL_CONTRACT,
|
||||
"%s: module initialization failed: %V",
|
||||
errname,
|
||||
srcm->modname);
|
||||
}
|
||||
|
||||
b = scheme_bucket_from_table(menv->toplevel, (const char *)srcname);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user