On 12 March 2018 at 10:06, Gianmaria Lari <gianmarial...@gmail.com> wrote:
> > > On 12 March 2018 at 09:25, David Kastrup <d...@gnu.org> wrote: > >> Gianmaria Lari <gianmarial...@gmail.com> writes: >> >> > On 11 March 2018 at 10:58, David Kastrup <d...@gnu.org> wrote: >> > >> >> Then Scheme expressions written using # in the middle of music are >> >> expected to be music expressions. >> > >> >> If you want to insert an actual >> >> duration, you need to write it preceded with $ so that it can have >> >> different type (and trigger different syntactic rules). >> >> >> >> But $8 is not a duration. $(ly:make-duration 3 0) would be a duration. >> > >> > >> > How does it work ? >> > Originary I thought that before source compilation, there was a step >> where >> > to replace scheme expressions with their evaluation, like a >> preprocessor; >> > that's why I tried c#(+ 6 2). But ok, it's clear it doesn't work in this >> > way. >> > >> > Is this handled by the lilypond parser that create a parse tree and then >> > according position in the tree and # or $ it expects different types? >> > >> > Thank you, g. >> >> From the "Extending LilyPond" guide: >> >> 1.2.1 LilyPond Scheme syntax >> ---------------------------- >> >> The Guile interpreter is part of LilyPond, which means that Scheme can >> be included in LilyPond input files. There are several methods for >> including Scheme in LilyPond. >> >> The simplest way is to use a hash mark ‘#’ before a Scheme >> expression. >> >> Now LilyPond’s input is structured into tokens and expressions, much >> like human language is structured into words and sentences. LilyPond >> has a lexer that recognizes tokens (literal numbers, strings, Scheme >> > [....] > > Ok David, I think it's clear. Thanks a lot for the very detailed > explanation, I appreciated your help. > g. > David, in a musical expression the scheme expression #(.....) must return a musical expression. That's ok. In case of I'm not inside a musical expression, does lilypond expect that the scheme expression #(.....) return something compatible with what "is on the left"? For example in this (working) code, on the left we have "piece" that needs a string on the right. So, on the right the scheme expression have to return a string to have working code. Is my comprehension correct? \version "2.19.81" \score { \header { piece = #(number->string 123) } \fixed c' { a a a a} } Thank you, g.
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user