diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-04-08 11:56:16 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-04-09 23:32:49 +0200 |
commit | 928af4355700271bd16dc99ab702360fcf25c503 (patch) | |
tree | 33137f4b7bcd1475d32762c3a5227d4d702077fd /module | |
parent | Fix timezone accumelator. (diff) | |
download | calp-928af4355700271bd16dc99ab702360fcf25c503.tar.gz calp-928af4355700271bd16dc99ab702360fcf25c503.tar.xz |
Add mulit-set!
Diffstat (limited to '')
-rw-r--r-- | module/util.scm | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/module/util.scm b/module/util.scm index 249e2de2..25be0389 100644 --- a/module/util.scm +++ b/module/util.scm @@ -6,7 +6,7 @@ define-quick-record mod! sort* sort*! find-min) - #:replace (let*) + #:replace (let* set!) ) (define-public upstring->symbol (compose string->symbol string-upcase)) @@ -136,6 +136,21 @@ +;; Allow set to work on multiple values at once, +;; similar to Common Lisp's @var{setf} +;; @example +;; (set! x 10 +;; y 20) +;; @end example +;; Still requires all variables to be defined beforehand. +(define-syntax set! + (syntax-rules () + ((_ field val) + ((@ (guile) set!) field val)) + ((_ field val rest ...) + (begin ((@ (guile) set!) field val) + (set! rest ...))))) + ;; Like set!, but applies a transformer on the already present value. (define-syntax-rule (mod! field transform-proc) (set! field (transform-proc field))) |