Le 30/12/2022 à 13:51, David Kastrup a écrit :
However, it doesn't work right now for local variables, like function parameters, in #{ ... #}.I think you may underestimate the cost of magic involved with making #/$ integrate into local Scheme scoping. If you want Scheme semantics, $ offers those along with Scheme syntax.
What is the cost of that magic precisely? In the basic case of \ being used outside #{ #}, the extra cost of \ being supported in #{ #} would be an assv-ref into an empty alist of closures, i.e., ~0 cost. While parsing #{ #}, we'd catch \ in addition to # and $. We already read the entire #{ #} for that. I don't think catching \ would add much overhead to it. It would also make Guile evaluate one (lambda () <variable>) per use of \ in #{ #}, which I don't believe is costly. While evaluating the \, the parser would need to do an assv-ref into the closure alist, which in most cases will have under 10 elements (the number of '#' / '$' / '\' in the #{ #} expression). If the linear cost of assv-ref is a concern, an obvious improvement is to use a hash table. Overall, I don't see what could have a worrisome cost. Did I miss something?
OpenPGP_signature
Description: OpenPGP digital signature