[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ly:parser-include-string and include order...
From: |
Jean Abou Samra |
Subject: |
ly:parser-include-string and include order... |
Date: |
Sat, 10 Dec 2022 20:22:29 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 |
Hi,
This came up while debugging an issue in Frescobaldi's
layout control options panel (I'm updating it to be
compatible with LilyPond 2.23).
$ ls
included1.ily included2.ily include-order.ly
$ cat include-order.ly
\version "2.25.0"
#(begin
(define (inc filename)
(ly:parser-include-string (format #f "\\include \"~a\"" filename)))
(inc "./included1.ily")
(inc "./included2.ily"))
$ cat included1.ily
\version "2.25.0"
#(ly:message "included1.ily parsed")
$ cat included2.ily
\version "2.25.0"
#(ly:message "included2.ily parsed")
$ LC_ALL=C.UTF-8 ~/repos/lilypond/build/out/bin/lilypond include-order.ly
GNU LilyPond 2.25.0 (running Guile 3.0)
Processing `include-order.ly'
Parsing...
included2.ily parsed
included1.ily parsed
Success: compilation successfully completed
Notice in the log how included2.ily is parsed *before*
included1.ily. On the other hand, putting the two
calls to ly:parser-include-string in separate Scheme
forms instead of using begin yields the right order:
#(define (inc filename)
(ly:parser-include-string (format #f "\\include \"~a\"" filename)))
#(inc "./included1.ily")
#(inc "./included2.ily")
=>
included1.ily parsed
included2.ily parsed
My understanding of what happens in the first case is that
after the first ly:parser-include-string is executed, the
parser is in a state where its current file is included1.ily,
and the \include "included2.ily" instruction actually gets
inserted at the beginning of included1.ily.
Does anyone with more knowledge of the parser than me have
an opinion on which of these to do?
a) Open an issue; this is a problem that should be fixed.
b) Open an enhancement request about adding a proper interface
for programmatically including a file. I know you can do
#{ \include #x #}, but this is not the desired effect for
Frescobaldi: it loads the LilyPond code inside a #{ #} context.
c) Declare that this is fraught with difficulties and users should
Just Not Do That (™).
Thanks,
Jean
OpenPGP_signature
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- ly:parser-include-string and include order...,
Jean Abou Samra <=