Am Mo., 14. Juni 2021 um 16:53 Uhr schrieb Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>:
 
As a side note on naming, I think `fxmapping-accumulate' is a
good name; the only concern I have about it is that the very well-known
SICP used it to describe a fold procedure.

fxmapping-consume
 
There is another issue I've found with replacing Maybe or the
"expected tail-call" semantics in fxmapping-update.  Consider this
silly example:

    (fxmapping-update key
                      fxmap
                      (lambda (k v replace delete)     ; updater
                        (values 'deleted (delete))))

This must be valid if we state that invoking `delete' returns the
updated fxmapping.  However, I believe that this constrains
fxmapping-update to calling the updater procedure in tail-context,
which may be inconvenient for some implementations (i.e. those
using structures which are naturally constructed via recursion).

We have discussed a similar thing some time ago, haven't we?

Isn't it a good idea to specify that the update procedure is always called in tail-context?

Example:

(define alist-update
  (lambda (ls key updater)
    (call-with-prompt (default-prompt-tag)
      (lambda ()
        (let f ([ls ls])
          (cond
            [(null? ls) '()]
            [(eqv? (caar ls) key)
             (abort-to-prompt default-prompt-tag ls)]
            [else (cons (car ls) (f (cdr ls)))])))
      (lambda (k)
        (updater (caar ls) (cdar ls)
          (lambda (val)
            (k (cons (cons key val) (cdr ls))))
          (lambda ()
            (k (cdr ls))))))))

Here, I have been using Guile's versions of Felleisen's delimited control operators (the -F- version). In Schemes that do not support delimited continuations, you should be able to use call/cc to emulate them. In any case, this is a good example how expressive the functional programming languages Scheme can be. And it is another example of why I have been claiming that we really, really should get the foundations set up first. :)