diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2019-06-04 12:28:42 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2019-06-04 12:28:42 +0200 |
commit | bb01ca8a5d1dd78b1a17c9ebf3d914fe3ef2dc7a (patch) | |
tree | 875f2c6f073bf75494375920d55caaa062992921 | |
parent | b8cd9073f7d555d47802220a7286be1ad29a258b (diff) |
compile: Simplify expressions.
* modules/language/python/compile.scm (with-exit): Use "unless" and
"zero?".
(use): Use "unless" instead of single-armed "(if (not ...) ...)".
(set-doc): Same.
(setwrap): Use "match-lambda".
(gentable): Use "when".
(export-all): Flip "if".
-rw-r--r-- | modules/language/python/compile.scm | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/modules/language/python/compile.scm b/modules/language/python/compile.scm index d21b904..54b6f5b 100644 --- a/modules/language/python/compile.scm +++ b/modules/language/python/compile.scm @@ -99,8 +99,8 @@ (call-with-prompt exit-prompt (lambda () code ...) (lambda (k val) - (if (not (equal? val 0)) - (format #t "exit with error ~a~%" val)))))) + (unless (zero? val) + (format #t "exit with error ~a~%" val)))))) (define (get-exported-symbols name) "Return a list of exported symbols from the module with the given @@ -214,13 +214,13 @@ empty list." (eval-when (expand) (catch #t (lambda () - (if (not p) (reload-module (resolve-module 'l))) + (unless p (reload-module (resolve-module 'l))) (use-modules-- a ...)) (const #f))) (eval-when (eval load) (catch #t (lambda () - (if (not p) (reload-module (resolve-module 'l))) + (unless p (reload-module (resolve-module 'l))) (use-modules- a ...)) (lambda x (raise (ImportError ((@ (guile) format) @@ -817,10 +817,9 @@ empty list." (define-syntax-rule (setwrap u) (call-with-values (lambda () u) - (lambda (x . x*) - (if (null? x*) - x - (cons x x*))))) + (match-lambda + ((x) x) + (x x)))) #; (define-syntax-rule (setwrap u) @@ -973,8 +972,8 @@ empty list." (case-lambda (() (fluid-set! *doc* #f)) ((x) - (if (not (fluid-ref *doc*)) - (fluid-set! *doc* x))))) + (unless (fluid-ref *doc*) + (fluid-set! *doc* x))))) (define (u-it m) (if (and (eq? (list-ref m 0) 'language) @@ -1255,7 +1254,8 @@ empty list." (let ((? (catch #t (lambda () (Module (reverse l) (reverse xl)) #t) (const #f)))) - (if (eq? ? #t) (for-each dont-warn (get-exported-symbols l))) + (when ? + (for-each dont-warn (get-exported-symbols l))) `(,(C 'use) ,? ,l ,l)))) ((_ (#:from (("." . nn) . nm) . #f)) @@ -2967,9 +2967,9 @@ empty list." (module-re-export! mod (for ((x : (module-ref mod '__all__))) ((l '())) (let ((x (string->symbol (scm-str x)))) - (if (not (module-locally-bound? mod x)) - (cons x l) - l)) + (if (module-locally-bound? mod x) + l + (cons x l))) #:final l))))) (define (pkkk x) |