Re: coop - a concurrent ml-like wanna be (pre-SRFI) Amirouche 06 May 2021 19:36 UTC
On 2021-05-06 19:22, Marc Nieper-Wißkirchen wrote: > Am Do., 6. Mai 2021 um 18:28 Uhr schrieb Amirouche > <xxxxxx@hyper.dev>: > >> (lambda args >> ;; TODO: use chibi's match > > NB: Use `case-lambda` when possible. It is optimized in a number of > Schemes, while Chibi's match does not produce optimized code. Thanks. > More to the point: > How does your code cooperate with call/cc called by the user or the > exception system of Scheme (which includes exceptions and continuable > exceptions). It depends whether coop is implemented as a library or it is a builtin ambiant coop. If the Scheme has an ambient coop, there is no problems I can forsee. When it is a library on top of a standard Scheme, so far I only worked with an emulation of the ambiant coop. If the user capture a continuation outside a flow, then I did not plan what can happen. > Do you have to rewrite these things as well when you > emulate delimited continuations with call/cc? I do not understand the question. If the question is: > Do you need to re-implement call/cc or exceptions or continuable exceptions to implement coop? Then the answer is: no. So far, the prototype is implemented as a Chez library, using call/cc, call/1cc [1] and Chez POSIX threads procedures (a subset of SRFI-18). [1] https://cisco.github.io/ChezScheme/csug9.5/control.html#./control:s9 I started to implement a Scheme that targets a micro subset of Scheme where I re-implement call/cc with a trampoline plus CPS transformation. The goal is to benchmark that against Chez's call/cc. Eventually try to benchmark a program to be able to tell whether trampoline CPS transformation is fast enough (and look at memory usage). The problem I see with the current coop specification is that there is no equivalent of parameters. > > Does your code respect proper tail recursion (see section 5.2 in [1])? > I did not read that article, yet. Do tail calls recursions grow the stack with trampoline + CPS transformation? I have a working program that can compute factorial and fibonacci with tail call recursions without crashing my computer. > Marc > > -- [1] > https://www.cambridge.org/core/journals/journal-of-functional-programming/article/abs/monadic-framework-for-delimited-continuations/D99D1394370DFA8EA8428D552B5D8E7E -- Amirouche ~ https://hyper.dev