guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 06/17: srfi-18: Use lambda* optional arguments.


From: Andy Wingo
Subject: [Guile-commits] 06/17: srfi-18: Use lambda* optional arguments.
Date: Mon, 31 Oct 2016 21:39:37 +0000 (UTC)

wingo pushed a commit to branch master
in repository guile.

commit 7078218a9283877841983e22c6e4f5bb734d9288
Author: Andy Wingo <address@hidden>
Date:   Sun Oct 30 21:44:35 2016 +0100

    srfi-18: Use lambda* optional arguments.
    
    * module/srfi/srfi-18.scm (make-mutex, make-condition-variable): Use
      optional arguments.
---
 module/srfi/srfi-18.scm |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/module/srfi/srfi-18.scm b/module/srfi/srfi-18.scm
index b3a0643..6d74346 100644
--- a/module/srfi/srfi-18.scm
+++ b/module/srfi/srfi-18.scm
@@ -282,13 +282,12 @@
 ;; MUTEXES
 ;; These functions are all pass-thrus to the existing Guile implementations.
 
-(define make-mutex
-  (lambda name
-    (let ((n (and (pair? name) (car name)))
-         (m (threads:make-mutex 'unchecked-unlock 
-                                 'allow-external-unlock 
-                                 'recursive)))
-      (and n (hashq-set! object-names m n)) m)))
+(define* (make-mutex #:optional name)
+  (let ((m (threads:make-mutex 'unchecked-unlock
+                               'allow-external-unlock
+                               'recursive)))
+    (when name (hashq-set! object-names m name))
+    m))
 
 (define (mutex-name mutex)
   (hashq-ref object-names (check-arg-type threads:mutex? mutex "mutex-name")))
@@ -323,11 +322,10 @@
 ;; CONDITION VARIABLES
 ;; These functions are all pass-thrus to the existing Guile implementations.
 
-(define make-condition-variable
-  (lambda name
-    (let ((n (and (pair? name) (car name)))
-         (m (threads:make-condition-variable)))
-      (and n (hashq-set! object-names m n)) m)))
+(define* (make-condition-variable #:optional name)
+  (let ((m (threads:make-condition-variable)))
+    (when name (hashq-set! object-names m name))
+    m))
 
 (define (condition-variable-name condition-variable)
   (hashq-ref object-names (check-arg-type threads:condition-variable? 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]