aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2024-12-24 08:45:57 -0500
committerGravatar Peter McGoron 2024-12-24 08:45:57 -0500
commit066431d7865fdc0a25be4f5f8259fcd80ea45d3d (patch)
tree2da8eefe455944503bd1be10b1b0e81eabdb54a4
parentmake iterator-advance only take integers (diff)
Revert generic-iterator to allow for any value for iterator-advance
Scheme is a dynamic language, users should have the freedom to use whatever value they wish to advance the iterator or to use as the index. The implementations of iterator-advance I have written require case analysis anyways, so there is no point to adding a case analysis branch before them.
Diffstat (limited to '')
-rw-r--r--generic-iterator.scm7
-rw-r--r--string-iterator.scm2
2 files changed, 5 insertions, 4 deletions
diff --git a/generic-iterator.scm b/generic-iterator.scm
index ee5ac9e..960f9da 100644
--- a/generic-iterator.scm
+++ b/generic-iterator.scm
@@ -54,11 +54,10 @@
get-end-predicate
"no end predicate")
-(define-with-field-of-iterator (iterator-advance get-advance spaces)
+(define-invoke-field-of-iterator iterator-advance
+ get-advance
"no advance procedure"
- (if (not (integer? spaces))
- (error "must advance an integer amount" spaces)
- (get-advance spaces)))
+ spaces)
(define-invoke-field-of-iterator iterator-ref
get-ref
diff --git a/string-iterator.scm b/string-iterator.scm
index d37be01..bddf9c0 100644
--- a/string-iterator.scm
+++ b/string-iterator.scm
@@ -47,6 +47,8 @@
(string-cursor=? cursor (string-cursor-end str)))
(lambda (spaces)
(cond
+ ((not (integer? spaces))
+ (error "advance must be done in integer steps" spaces))
((not (string-cursor-valid-movement? str cursor spaces))
#f)
((negative? spaces)