lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A question about a scheme function with two input notes


From: Jean Abou Samra
Subject: Re: A question about a scheme function with two input notes
Date: Fri, 30 Dec 2022 14:55:22 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

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?

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]