lilypond-user
[Top][All Lists]
Advanced

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

Re: c#(+6 2)


From: David Kastrup
Subject: Re: c#(+6 2)
Date: Wed, 14 Mar 2018 10:13:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Gianmaria Lari <address@hidden> writes:

> On 12 March 2018 at 10:06, Gianmaria Lari <address@hidden> wrote:
>
>>
>>
>> On 12 March 2018 at 09:25, David Kastrup <address@hidden> wrote:
>>>
>>> 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.
>
> 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} }

I don't think that the type of assignments in header blocks and similar
is being checked.  But the later use of "piece" will require something
compatible with a "markup" which a plain quoted string is.

The difference between # and $ is mostly that # does not convey any
syntactical information to the parser and thus can be left unevaluated
until actually used in some expression.  $ produces a type relevant to
parsing, so you might get surprising "premature" evaluations when the
respective token is needed as a lookahead token for determining the
syntax.

In situations like assignments, the syntactic role of # is clear so
using $ is rarely called for.

-- 
David Kastrup



reply via email to

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