Fix modify macros to comply with the spec
They happened to work in SBCL before, but according to the spec
`define-modify-macro` takes only a symbol as the function argument,
not a lambda or anything else.
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 20 Aug 2016 21:03:44 +0000 |
parents |
70f3c369fedb
|
children |
e21b181efc55
|
branches/tags |
(none) |
files |
losh.lisp |
Changes
--- a/losh.lisp Sat Aug 20 13:25:22 2016 +0000
+++ b/losh.lisp Sat Aug 20 21:03:44 2016 +0000
@@ -280,17 +280,20 @@
(define-modify-macro mulf (factor) *
"Multiply `place` by `factor` in-place.")
-(define-modify-macro divf (&optional divisor)
- (lambda (value divisor)
- (if divisor
- (/ value divisor)
- (/ value)))
+
+(defun %divf (value &optional divisor)
+ (if divisor
+ (/ value divisor)
+ (/ value)))
+
+(define-modify-macro divf (&optional divisor) %divf
"Divide `place` by `divisor` in-place.
If `divisor` is not given, `place` will be set to `(/ 1 place)`.
")
+
(define-modify-macro modf (divisor) mod
"Modulo `place` by `divisor` in-place.")
@@ -304,11 +307,13 @@
"Negate the value of `place`.")
-(define-modify-macro %callf (function)
- (lambda (value function)
- (funcall function value))
+(defun %funcall (value function)
+ (funcall function value))
+
+(define-modify-macro %callf (function) %funcall
"Set `place` to the result of calling `function` on its current value.")
+
(defmacro callf (&rest place-function-pairs)
"Set each `place` to the result of calling `function` on its current value.