aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-05-03 16:43:43 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-05-03 16:43:43 +0200
commit6bf1d1f81ae1dcbd500f13086f2c1234635e1876 (patch)
tree2ee744d7db1b2e9b8a1c9506de71b58736856f59
parentCreate module (vcomponent base). (diff)
downloadcalp-6bf1d1f81ae1dcbd500f13086f2c1234635e1876.tar.gz
calp-6bf1d1f81ae1dcbd500f13086f2c1234635e1876.tar.xz
Replace if.
-rw-r--r--module/util.scm34
1 files changed, 20 insertions, 14 deletions
diff --git a/module/util.scm b/module/util.scm
index 2a995777..7dc2542c 100644
--- a/module/util.scm
+++ b/module/util.scm
@@ -10,7 +10,7 @@
quote?
tree-map let-lazy)
#:replace (let* set! define-syntax
- when unless))
+ when unless if))
((@ (guile) define-syntax) define-syntax
(syntax-rules ()
@@ -21,7 +21,24 @@
((_ otherwise ...)
((@ (guile) define-syntax) otherwise ...))))
-(define-public unspecified (if #f #f))
+(define-public *unspecified* ((@ (guile) if) #f #f))
+
+
+
+(define-syntax-rule (when pred body ...)
+ (if pred (begin body ...) '()))
+
+(define-syntax-rule (unless pred body ...)
+ (if pred '() (begin body ...)))
+
+(define-syntax if
+ (syntax-rules ()
+ [(_ p t)
+ (when p t)]
+
+ [(_ p t f ...)
+ ((@ (guile) if) p t
+ (begin f ...))]))
@@ -31,7 +48,6 @@
(define-public symbol-downcase (compose string->symbol string-downcase symbol->string))
-
(define-syntax for
(syntax-rules (in)
((for <var> in <collection> b1 body ...)
@@ -79,9 +95,6 @@
-
-
-
;; Replace let* with a version that can bind from lists.
;; Also supports SRFI-71 (extended let-syntax for multiple values)
;; @lisp
@@ -142,13 +155,6 @@
-(define-syntax-rule (when pred body ...)
- (if pred (begin body ...) '()))
-
-(define-syntax-rule (unless pred body ...)
- (if pred '() (begin body ...)))
-
-
;; Allow set to work on multiple values at once,
;; similar to Common Lisp's @var{setf}
@@ -176,7 +182,7 @@
;; Like set!, but applies a transformer on the already present value.
(define-syntax mod!
(syntax-rules (=)
- ((_) unspecified)
+ ((_) *unspecified*)
((_ field = proc)
(modf% field = proc))