Thanks. I was implementing with-continuation-mark by just pushing key&value to the current dynamic environment (and let the newest shadow the previous one), but realized that the simple tail-call loop makes the dynamic environment keeps growing.
It is, although, somewhat tricky if marks are interleaved. (let loop () (with-continuation-mark 'a 1 (with-continuation-mark 'b 2 (with-continuation-mark 'a 3 (with-continuation-mark 'b 4 (loop)))))) So far, what I'm thinking is that each with-continuation-mark searches the marks in the current continuation and reconstruct the alist of marks if it's overriding the previous mark. Is there a better way than that? --shiro On Wed, Oct 26, 2022 at 10:48 AM Marc Nieper-Wißkirchen < marc.nie...@gmail.com> wrote: > Yes, indeed. The inner `with-continuation-mark' just replaces > (non-destructively) the value of the mark "a". > > The tail-call guarantee is essential for several use cases of > continuation marks. One is debugging; you can attach debugging > information to frames, but you want to retain proper tail calls while > doing so. > > Am Mi., 26. Okt. 2022 um 22:22 Uhr schrieb Shiro Kawai < > shiro.ka...@gmail.com>: > > > > Quick question. The following code is expected to run in a bounded > space, correct? > > > > (let loop () > > (with-continuation-mark 'a 'b > > (with-continuation-mark 'a 'c > > (loop)))) > > > > >