[racket] Semaphore obscurities

From: Tobias Hammer (tobias.hammer at dlr.de)
Date: Thu Sep 27 04:37:06 EDT 2012

According to [1] this is the expected behavior. There is stated that

"When a “rest argument” is declared after optional arguments, arguments
in an application are first consumed by the optional-argument positions,
so the rest argument is non-empty only when more arguments
are provided that the total number of required and optional
arguments."

Unfortunately this or a similar explanation is missing in the manual. Maybe
it should be mentioned there.

Regards,
Tobias


[1] Keyword and Optional Arguments in PLT Scheme, Flatt; Barzilay



On Wed, 26 Sep 2012 22:46:20 +0200, Norman Gray <norman at astro.gla.ac.uk>  
wrote:

>
> Greetings
>
> The behaviour of call-with-semaphore doesn't appear to match the  
> documentation, or else I'm misunderstanding the documentation.
>
> Consider:
>
> (define (printit m)
>   (printf "msg begin:~a~%" m))
> (define try
>   (let ((sema (make-semaphore 1)))
>     (λ (msg)
>       (call-with-semaphore sema
>                            printit
>                            ;#f
>                            msg))))
> (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	 	 	 	
>  	 	proc	 	 	 	
>  	 [	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
>
>


-- 
---------------------------------------------------------
Tobias Hammer
DLR / Institute of Robotics and Mechatronics
Muenchner Str. 20, D-82234 Wessling
Tel.: 08153/28-1487
Mail: tobias.hammer at dlr.de


Posted on the users mailing list.