Order & priority of ambient restarters
Wolfgang Corcoran-Mathe 14 Nov 2023 19:26 UTC
Hi John and the SRFI 249 ml,
Should an implementation of SRFI 249 maintain some kind of order
among the ambient restarters? In particular, do we care whether
'with-restarters' reorders the result of '(ambient-restarters)'? The
spec says that 'with-restarters' "establishes restarters ... as
ambient restarters *on top of* the existing ambient restarters"
(emphasis mine). Should this be understood to mean that the following
returns '(b a ...)' (where ... refers to any already-established
ambient restarters)?
(define rA (make-restarter 'a '("restarter A") values))
(define rB (make-restarter 'b '("restarter B") values))
(with-restarters
rA
(lambda ()
(with-restarters
rB
(lambda ()
(map restarter-tag (ambient-restarters))))))
At the moment, the tests assume that, if there are no prior ambient
restarters, either '(b a)' or '(a b)' is a valid result here.
It would simplify things to make "the ambient restarters" a list,
and to make '(with-restarters restarters thunk)' equivalent to
(parameterize ((ambient-restarters
(collect-restarters restarters)))
(thunk))
since 'collect-restarters' has clear-ish priority semantics. But this
would break other implementations that might conform to the SRFI.
What if we want to store the ambient restarters in a bag, and have
'ambient-restarters' project that bag to a list in unspecified order?
It's also possible to get several ambient restarters with the
same tag using these nested 'with-restarters' expressions,
since 'w.-r.' doesn't check its *restarters* argument against
'(ambient-restarters)':
(define rA (make-restarter 'a '("foo") values))
(define rA* (make-restarter 'a '("bar") values))
(with-restarters
rA
(lambda ()
(with-restarters
rA*
(lambda ()
(list
(map restarter-tag (ambient-restarters)))))))
=> (a a ...) [or (... a ... a ...)?]
I'm not sure if this is important.
I also think that "Returns the current list of ambient restarters"
in the 'ambient-restarters' spec should be changed to "Returns a
list of the current ambient restarters". The list can be
ephemeral--right?
Regards,
Wolf
--
Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>