summaryrefslogtreecommitdiffstats
path: root/srfi
diff options
context:
space:
mode:
authorGravatar Arvydas Silanskas 2021-11-27 12:42:08 +0200
committerGravatar Arvydas Silanskas 2021-11-27 12:42:08 +0200
commit94e1038d09422202c8b55c57407ac29d08826f08 (patch)
tree89a42a2b2c40943f721e7f01471201a21a36798c /srfi
parentdto and find-update (diff)
srfi125 find-update add thunk indirection to enforce tail position
Diffstat (limited to 'srfi')
-rw-r--r--srfi/srfi-125-impl.scm17
1 files changed, 11 insertions, 6 deletions
diff --git a/srfi/srfi-125-impl.scm b/srfi/srfi-125-impl.scm
index 1d5cf8e..bbc5543 100644
--- a/srfi/srfi-125-impl.scm
+++ b/srfi/srfi-125-impl.scm
@@ -72,7 +72,10 @@
table))
(define (t125-hash-table-find-update* dto table key fail success)
- (define (handle-success value)
+ ;; instead of running immediately,
+ ;; add an indirection through thunk
+ ;; to guarantee call in tail position
+ (define (make-success-thunk value)
(define (update new-key new-value)
(guard-immutable table
(unless (eq? new-key key)
@@ -83,18 +86,20 @@
(guard-immutable table
(t125-hash-table-delete! table key)
table))
- (success key value update remove))
- (define (handle-fail)
+ (lambda ()
+ (success key value update remove) ))
+ (define (make-failure-thunk)
(define (ignore)
table)
(define (insert value)
(guard-immutable table
(t125-hash-table-set! table key value)
table))
- (fail insert ignore))
+ (lambda ()
+ (fail insert ignore)))
- (define default (cons #f #f))
- (t125-hash-table-ref table key handle-fail handle-success))
+ (define thunk (t125-hash-table-ref table key make-failure-thunk make-success-thunk))
+ (thunk))
(define (t125-hash-table-comparator* dto table)
(make-comparator (lambda args #t)
le='2021-07-26 16:10:31 -0700'>2021-07-26typoGravatar John Cowan 1-1/+1 2021-07-26switching to explicit dtosGravatar John Cowan 1-88/+102 2021-07-26errorsGravatar John Cowan 1-1/+4 2021-07-26more MN-W reviewGravatar John Cowan 1-5/+5 2021-07-26update preview linkGravatar John Cowan 1-1/+1 2021-07-26MN-W reviewGravatar John Cowan 1-6/+6 2021-07-26paired mutatorsGravatar John Cowan 1-43/+68 2021-07-25exceptionsGravatar John Cowan 1-1/+15 2021-07-25new exampleGravatar John Cowan 1-1/+4 2021-07-25updatesGravatar John Cowan 1-2/+4 2021-07-24dtd always first argumentGravatar John Cowan 1-9/+9 2021-07-23DTO to DTDGravatar John Cowan 1-55/+52 2021-07-22typoGravatar John Cowan 1-1/+1 2021-07-22switching to explicit dtosGravatar John Cowan 1-88/+102 2021-07-22errorsGravatar John Cowan 1-1/+4 2021-07-22more MN-W reviewGravatar John Cowan 1-5/+5 2021-07-20update preview linkGravatar John Cowan 1-1/+1 2021-07-20MN-W reviewGravatar John Cowan 1-6/+6 2021-07-18Fix typo.Gravatar Arthur A. Gleckler 2-4/+4 2021-07-18Add <p> around abstract.Gravatar Arthur A. Gleckler 1-2/+2 2021-07-18Publish first draft.draft-1Gravatar Arthur A. Gleckler 3-0/+114 2021-07-18Ignore trailing whitespace.Gravatar Arthur A. Gleckler 11-129/+129 2021-07-18Ignore "Dictionaries.log".Gravatar Arthur A. Gleckler 1-1/+2 2021-07-18Fix errors reported by W3C HTML Validator.Gravatar Arthur A. Gleckler 1-27/+27 2021-07-18Eliminate unnecessary redirect by using TLS/SSL.Gravatar Arthur A. Gleckler 1-1/+1