Re: \include inside function

2022-02-01 Thread Valentin Petzel
Hello Jean, I expected something like this might be possible, thank you for this simple solution! I surely could not have done this this elegantly! Maybe I’ll try to extend this to allow for specifying paths. Maybe also it could work to set custom toplevel handlers to have scores and

Re: \include inside function

2022-02-01 Thread Valentin Petzel
> You won't get far without parsing the file. I was rather talking about the relevant functionality essentially being done after parsing the included file. > Feel free to create an implementation. That will apparently be easier > than to prove viability to me. First I’ll have to do some

Re: \include inside function

2022-02-01 Thread David Kastrup
David Wright writes: > On Tue 01 Feb 2022 at 16:09:01 (+0100), Leo Correia de Verdier wrote: >> >> Is there a way to have an \include inside a function? >> In the attached file includeinfunction.ly the commented out line >> doesn’t work (probably for some very logical reason, but still >>

Re: \include inside function

2022-02-01 Thread David Kastrup
Valentin Petzel writes: >> And it still breaks down because at the top level, LilyPond input does >> not reflect a static structure but directs actions, actions that have >> immediate consequences _while_ still reading ahead. > > I do not understand why this matters here? Doesn’t this only

Re: \include inside function

2022-02-01 Thread Jean Abou Samra
Le 01/02/2022 à 23:14, Jean Abou Samra a écrit : Well, if you are ready to get evil, you can do \version "2.23.5" includeNamespace = #(define-scheme-function (filename) (string?)    (let ((new-parser (ly:parser-clone))) (ly:parser-parse-string   new-parser   (format #f "\\include

Re: \include inside function

2022-02-01 Thread Valentin Petzel
> Since you removed every single bit of context, it's not even possible to > say anymore what you want to be talking about. But I’ve been saying this since the beginning. The idea would be to have a way to parse a ly file (or a string) within a different scope, and then make the scope

Re: \include inside function

2022-02-01 Thread Jean Abou Samra
Le 01/02/2022 à 20:10, Valentin Petzel a écrit : Hello David, An assignment basically adds a pair (symbol, value) to some assignment table. So shouldn’t it be possible to parse a file with a new assignment table and then convert this assignment table into a scheme accessible structure? I do

Re: \include inside function

2022-02-01 Thread Valentin Petzel
> That's just wild handwaving. Something like > > bing = cis' > bing = { $bing 2-2 } > \score { > \bing > } > > does not resolve in such a manner since the _structure_ of the > expression containing $bing cannot be resolved without knowing the type > of bing at the time $bing is encountered.

Re: \include inside function

2022-02-01 Thread David Kastrup
Valentin Petzel writes: > Hello David, > > An assignment basically adds a pair (symbol, value) to some assignment table. > So shouldn’t it be possible to parse a file with a new assignment table and > then convert this assignment table into a scheme accessible structure? That's just wild

Re: \include inside function

2022-02-01 Thread Valentin Petzel
> And it still breaks down because at the top level, LilyPond input does > not reflect a static structure but directs actions, actions that have > immediate consequences _while_ still reading ahead. I do not understand why this matters here? Doesn’t this only matter while we are parsing the

Re: \include inside function

2022-02-01 Thread David Kastrup
Valentin Petzel writes: >> Since you removed every single bit of context, it's not even possible to >> say anymore what you want to be talking about. > > But I’ve been saying this since the beginning. The idea would be to have a > way > to parse a ly file (or a string) within a different

Re: \include inside function

2022-02-01 Thread David Kastrup
Valentin Petzel writes: >> That's just wild handwaving. Something like >> >> bing = cis' >> bing = { $bing 2-2 } >> \score { >> \bing >> } >> >> does not resolve in such a manner since the _structure_ of the >> expression containing $bing cannot be resolved without knowing the type >> of

Re: \include inside function

2022-02-01 Thread Valentin Petzel
Hello Leo, Here are two ways to do it, one by using \include and one directly parsing the contents of the file. Cheers, Valentin Am Dienstag, 1. Februar 2022, 16:09:01 CET schrieb Leo Correia de Verdier: > Dear list! > > Is there a way to have an \include inside a function? > In the attached

Re: \include inside function

2022-02-01 Thread Valentin Petzel
Hello David, An assignment basically adds a pair (symbol, value) to some assignment table. So shouldn’t it be possible to parse a file with a new assignment table and then convert this assignment table into a scheme accessible structure? I do not mean to say that assignments should not be

Re: \include inside function

2022-02-01 Thread David Kastrup
Valentin Petzel writes: > Hi David! > > I suppose it might be useful to have something like a parsing function > that does parse a file internally, but returns a scheme structure > containing all variables, functions, scores, books, whatever defined > in that file. This would make using stuff in

Re: \include inside function

2022-02-01 Thread Valentin Petzel
Hi David! I suppose it might be useful to have something like a parsing function that does parse a file internally, but returns a scheme structure containing all variables, functions, scores, books, whatever defined in that file. This would make using stuff in a different file much more clean

Re: \include inside function

2022-02-01 Thread David Wright
On Tue 01 Feb 2022 at 16:09:01 (+0100), Leo Correia de Verdier wrote: > > Is there a way to have an \include inside a function? > In the attached file includeinfunction.ly the commented out line doesn’t work > (probably for some very logical reason, but still unknown to me). Is there a > way to

Re: \include inside function

2022-02-01 Thread David Kastrup
Leo Correia de Verdier writes: > Dear list! > > Is there a way to have an \include inside a function? > In the attached file includeinfunction.ly the commented out line > doesn’t work (probably for some very logical reason, but still unknown > to me). Uh, if you write the content of the