diff options
author | Chris K. Jester-Young <cky944@gmail.com> | 2013-03-19 08:39:00 -0400 |
---|---|---|
committer | Chris K. Jester-Young <cky944@gmail.com> | 2013-03-19 08:39:00 -0400 |
commit | a703d83f5bfb324f601b096b5aab1b50e6715541 (patch) | |
tree | fa272f39d59b413c0aa2f8d47531d3500274fe46 | |
parent | c33f45bef09523bea1545845c41cc6eb9068d6ae (diff) | |
download | guile-a703d83f5bfb324f601b096b5aab1b50e6715541.tar.gz |
Implement more feedback from Mark H. Weaver.
* module/srfi/srfi-41.scm (must, must-not, must-every): Implement
these as direct macros, and without using negate.
-rw-r--r-- | module/srfi/srfi-41.scm | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/module/srfi/srfi-41.scm b/module/srfi/srfi-41.scm index 45b03ad3b..314127eee 100644 --- a/module/srfi/srfi-41.scm +++ b/module/srfi/srfi-41.scm @@ -44,23 +44,20 @@ ;;; Private supporting functions and macros. -(define-syntax-rule (must-not1 pred obj func msg args) - (when (pred obj) - (throw 'wrong-type-arg func msg args (list obj)))) - -(define-syntax-rule (must-not* pred objs func msg args) - (let ((flunk (filter pred objs))) +(define-syntax-rule (must pred obj func msg args ...) + (let ((item obj)) + (unless (pred item) + (throw 'wrong-type-arg func msg (list args ...) (list item))))) + +(define-syntax-rule (must-not pred obj func msg args ...) + (let ((item obj)) + (when (pred item) + (throw 'wrong-type-arg func msg (list args ...) (list item))))) + +(define-syntax-rule (must-every pred objs func msg args ...) + (let ((flunk (remove pred objs))) (unless (null? flunk) - (throw 'wrong-type-arg func msg args flunk)))) - -(define* (must-not pred obj func msg . args) - (must-not1 pred obj func msg args)) - -(define* (must pred obj func msg . args) - (must-not1 (negate pred) obj func msg args)) - -(define* (must-every pred objs func msg . args) - (must-not* (negate pred) objs func msg args)) + (throw 'wrong-type-arg func msg (list args ...) flunk)))) ; Only the one-list version is supported since that's what we use. (define (pair-map proc clist) |