[racket] Semaphore obscurities

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Wed Sep 26 16:46:20 EDT 2012


The behaviour of call-with-semaphore doesn't appear to match the documentation, or else I'm misunderstanding the documentation.


(define (printit m)
  (printf "msg begin:~a~%" m))
(define try
  (let ((sema (make-semaphore 1)))
    (λ (msg)
      (call-with-semaphore sema
(try "second")

With #f commented out, I get (with Racket 5.3):

call-with-semaphore: procedure arity does not match extra-argument count
  procedure: #<procedure:printit>
  extra-argument count: 0

With #f uncommented, it works as expected:

Welcome to DrRacket, version 5.3 [3m].
Language: racket; memory limit: 128 MB.
msg begin:second

The documentation says:

(call-with-semaphore	 	sema	 	 	 	 
 	 [	try-fail-thunk]	 	 	 	 
 	 	arg ...)	 	→	 	any

However it appears that the try-fail-chunk argument is not in fact optional.


Separately, it appears that CALL-WITH-SEMAPHORE returns the value that (proc args…) returns.  However the documentation doesn't actually say that.  Is that just an oversight, or is the return value of CALL-WITH-SEMAPHORE undefined?

Best wishes,


Norman Gray  :  http://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK

Posted on the users mailing list.