From 4effd7b8973373d6e6f280cb15bfd79c082ac066 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 15 May 2008 17:29:49 +0000 Subject: [PATCH] doc clarifications (PR 9307) and arity issue (PR 9025) svn: r9855 --- collects/mzlib/scribblings/thread.scrbl | 5 +--- collects/mzlib/thread.ss | 19 +++++------- .../scribblings/reference/cont-marks.scrbl | 29 ++++++++++++------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/collects/mzlib/scribblings/thread.scrbl b/collects/mzlib/scribblings/thread.scrbl index 1d909c3e93..71b61e92d7 100644 --- a/collects/mzlib/scribblings/thread.scrbl +++ b/collects/mzlib/scribblings/thread.scrbl @@ -65,10 +65,7 @@ it is still running, leaving the coroutine result unchanged.} (values thread? procedure?)]{ Returns two values: a thread descriptor for a new thread, and a -procedure with the same arity as @scheme[f]. (The returned procedure -actually accepts any number of arguments, but immediately raises -@scheme[exn:fail:contract:arity] if @scheme[f] cannot accept the -provided number of arguments.) +procedure with the same arity as @scheme[f]. When the returned procedure is applied, its arguments are queued to be passed on to @scheme[f], and @|void-const| is immediately returned. diff --git a/collects/mzlib/thread.ss b/collects/mzlib/thread.ss index 2021da1c72..0dcf5c6b77 100644 --- a/collects/mzlib/thread.ss +++ b/collects/mzlib/thread.ss @@ -41,18 +41,13 @@ (lambda () (init) (loop)))) - (lambda new-state - (let ([num (length new-state)]) - (unless (procedure-arity-includes? f num) - (raise - (make-exn:fail:contract:arity - (format ": consumer procedure arity is ~e; provided ~s argument~a" - (procedure-arity f) num (if (= 1 num) "" "s")) - (current-continuation-marks))))) - (semaphore-wait protect) - (set! front-state (cons new-state front-state)) - (semaphore-post protect) - (semaphore-post sema))))) + (procedure-reduce-arity + (lambda new-state + (semaphore-wait protect) + (set! front-state (cons new-state front-state)) + (semaphore-post protect) + (semaphore-post sema)) + (procedure-arity f))))) (define/kw (run-server port-number handler connection-timeout #:optional diff --git a/collects/scribblings/reference/cont-marks.scrbl b/collects/scribblings/reference/cont-marks.scrbl index ca23012851..a77b3d0263 100644 --- a/collects/scribblings/reference/cont-marks.scrbl +++ b/collects/scribblings/reference/cont-marks.scrbl @@ -121,19 +121,26 @@ Returns @scheme[#t] if @scheme[v] is a mark set created by [mark-set continuation-mark-set?]) list?]{ -Returns a list representing a ``@index["stack dump"]{@as-index{stack -trace}}'' for @scheme[mark-set]'s continuation. The list contains -pairs, where the @scheme[car] of each pair contains either @scheme[#f] -or a symbol for a procedure name, and the @scheme[cdr] of each pair -contains either @scheme[#f] or a @scheme[srcloc] value for the -procedure's source location (see @secref["linecol"]); the -@scheme[car] and @scheme[cdr] are never both @scheme[#f]. +Returns a list representing an approximate ``@index["stack +dump"]{@as-index{stack trace}}'' for @scheme[mark-set]'s +continuation. The list contains pairs, where the @scheme[car] of each +pair contains either @scheme[#f] or a symbol for a procedure name, and +the @scheme[cdr] of each pair contains either @scheme[#f] or a +@scheme[srcloc] value for the procedure's source location (see +@secref["linecol"]); the @scheme[car] and @scheme[cdr] are never both +@scheme[#f]. -The stack-trace list is the result of +Conceptually, the stack-trace list is the result of @scheme[continuation-mark-set->list] with @scheme[mark-set] and -Scheme's private key for procedure-call marks. A stack trace is -extracted from an exception and displayed by the default error display -handler (see @scheme[current-error-display-handler]) for exceptions other than +Scheme's private key for procedure-call marks. The implementation may +be different, however, and the results may merely approximate the +correct answer. Thus, while the result may contain useful hints to +humans about the context of an expression, it is not reliable enough +for programmatic use. + +A stack trace is extracted from an exception and displayed by the +default error display handler (see +@scheme[current-error-display-handler]) for exceptions other than @scheme[exn:fail:user] (see @scheme[raise-user-error] in @secref["errorproc"]).}