Jean Abou Samra <j...@abou-samra.fr> writes: > Le 21/04/2022 à 10:38, Han-Wen Nienhuys a écrit : >> On Thu, Apr 21, 2022 at 12:04 AM Jean Abou Samra <j...@abou-samra.fr> wrote: >>> I am working on code that pervasively utilizes Guile fluids. They should >>> be set in dynamic scopes. >> That sounds scary. Care to tell more? > > What is scary about it exactly? > > I am trying to reimplement purity in terms of fluids, so the set of > parameters is not hardcoded to 'start, end' and all the code doesn't > have to be littered with functions working both as pure and impure and > forwarding start/end to the property callbacks they > cause.
Good. > Essentially, this should look like { Dynwind_context dwc; > dwc->make_assumption (Lily::prebreak_estimate, SCM_BOOL_T); > ... get_property (grob, "property") ... } or in Scheme: > (under-assumptions ((*prebreak-estimate* #t)) ...) and by virtue of > the dynamic context, the callback that computes the grob property > understands that it should do pure estimates. My personal take on this would move the magic out of the normal reach of users. You get (*start-column*) and (*end-column*) which you can use for accessing the respective fluids but the function *start-column* does not merely access %start-column but it also registers the associated impurity for the sake of caching. This also helps by not registering impurities that don't arise for a particular grob (things like breakpoint-depending accidentals comparatively rarely rise to the level of actual relevance but get everything dealt with as impure, with the associated costs, all the time). > I haven't gotten as far as a working proof of concept, but I expect a > speedup. This is essentially a remix of an idea from David: > https://lists.gnu.org/archive/html/lilypond-devel/2015-05/msg00397.html I probably repeat myself... -- David Kastrup