compile: get-addings: Implement without aif.
authorRicardo Wurmus <rekado@elephly.net>
Tue, 4 Jun 2019 09:50:02 +0000 (11:50 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Tue, 4 Jun 2019 09:50:02 +0000 (11:50 +0200)
* modules/language/python/compile.scm (aif): Remove macro.
(get-addings): Implement without aif; simplify.

modules/language/python/compile.scm

index c52905b..c0513c4 100644 (file)
@@ -23,8 +23,6 @@
   #:use-module (ice-9 pretty-print)
   #:export (comp exit-fluid exit-prompt pks do-pr))
 
-(define-syntax-rule (aif it p x y) (let ((it p)) (if it x y)))
-
 (define-inlinable (C   x) `(@@ (language python compile) ,x))
 (define-inlinable (F2  x) `(@@ (language python format2) ,x))
 (define-inlinable (N   x) `(@@ (language python number)  ,x))
@@ -796,18 +794,20 @@ empty list."
            (let* ((tag     (exp vs x))
                   (xs      (gensym "xs"))
                   (fast    (fastfkn tag))
-                  (is-fkn? (aif it (and fast? is-fkn? fast)
-                                `(#:call-obj (lambda (e)
-                                               (lambda ,xs
-                                                 (,(G 'apply) ,it e ,xs))))
-                                #f)))
-             (if is-fkn?
-                 is-fkn?
-                 (if (and fast? fast)
-                     `(#:fastfkn-ref ,fast (,(G 'quote) ,tag))
-                     (aif it (and fast? (fast-ref tag))
-                          `(#:fast-id ,it (,(G 'quote) ,tag))
-                          `(#:identifier (,(G 'quote) ,tag)))))))
+                  (is-fkn? (and=> (and fast? is-fkn? fast)
+                                  (lambda (it)
+                                    `(#:call-obj (lambda (e)
+                                                   (lambda ,xs
+                                                     (,(G 'apply) ,it e ,xs))))))))
+             (cond
+              (is-fkn? is-fkn?)
+              ((and fast? fast)
+               `(#:fastfkn-ref ,fast (,(G 'quote) ,tag)))
+              ((and fast? (fast-ref tag)) =>
+               (lambda (it)
+                 `(#:fast-id ,it (,(G 'quote) ,tag))))
+              (else
+               `(#:identifier (,(G 'quote) ,tag))))))
           
           ((#:arglist args)
            `(#:apply ,@(get-kwarg vs args)))