Am Fr., 28. Okt. 2022 um 21:14 Uhr schrieb Vincent Manis <vma...@telus.net>: > > On 2022-10-28 11:58, Marc Nieper-Wißkirchen wrote: > > > IMO, it is actually a good thing for the name to be quite different > > from Scheme's dynamic-wind. Dynamic-wind is built so that control can > > leave and enter the THUNK several times and has the notion of a > > BEFORE-THUNK. The first is forbidden and the latter is not the case > > for unwind-protect. Moreover, unwind-protect is syntax, while > > dynamic-wind-once would probably be expected to be a procedure as > > well. > > > > What do you think? > > Well, we have a procedure and a special form that do essentially similar > things, namely ensuring that some cleanup code is executed when the > protected form is exited, and yet one's name includes “wind” and the > other's includes “unwind”. At the risk of saying something > flammable/inflammable, this seems needlessly confusing. Perhaps > `dynamic-wind' should have been called something else (though there were > good reasons for choosing that name), but that ship has sailed.
The point of unwind-protect is that the cleanup code is run (once and without an exception bar thread termination). The point of dynamic-wind is to extend the dynamic environment (meant in a generalized sense) during the dynamic extent of the THUNK. These are pretty different things conceptually. I am not saying that dynamic-wind is necessarily a good name, but as you say, we cannot change it anymore. On the other hand, changing the name unwind-protect won't help anyone who knows it from Common Lisp. A third name implies that people may think there is a third concept besides dynamic-wind and unwind-protect. > Could this new form be called `wind-protect'? I am not convinced; I fear that this will cause more confusion than it tries to solve. John initially proposed adding unwind-protect, maybe he can chime in as well. > I also think it's necessary to have an explanation about the differences > between dynamic-wind and this new form. It's not obvious to me that a > (human) reader would grasp the need for both without a few sentences > explaining the intended uses. I can add a sentence pointing out the use of unprotect-wind for cleanup purposes. I should also add a remark that the syntax has its origins in CL, explaining the name.