[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: simple scheme in lilypond
From: |
David Kastrup |
Subject: |
Re: simple scheme in lilypond |
Date: |
Tue, 27 Nov 2018 12:11:47 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Gianmaria Lari <address@hidden> writes:
> Probably these are very trivial things. Sorry to ask them but would like to
> understand.
>
> If I write (1):
>
>
> \version "2.19.82"
> $(object->string (+ 3 2))
>
>
> Lilypond is happy and compile to a pdf file showing "5".
>
> Even this simpler code works... (2)
>
> \version "2.19.82"
> $"Hello"
>
>
> and generate a pdf file showing "Hello".
>
> It is clear to me that $ introduce a scheme expression that is evaluated.
> And in the previous two examples the scheme code is evaluated to strings.
> But I don't understand why lilypond outputs them. If I write (3):
>
> \version "2.19.82"
> "Test"
blabla = "Test"
##f
\blabla
will compile again (sorry for the ##f : it is necessary to defeat
lookahead). It is indistinguishable from
blabla = \markup "Test"
##f
\blabla
in output and in its effect on the variable. Basically, $x and \x are
the same (apart from the characters allowed in and after x). The
logical thing would be to permit "Test" on its own but it appears rather
error-prone. This is similar to
blabla = c4
##f
\blabla
compiling and producing a result while
c4
on its own doesn't.
> I tried to rewrite (1) and (2) with the hash mark instead of dollar (6):
>
> \version "2.19.82"
> #(object->string (+ 3 2))
>
>
> and (7):
>
> \version "2.19.82"
> #"Hello"
>
>
> This time, there is no output in the pdf file. Why this difference?
At the top level of the file, assignments and assignment-like statements
may be executed. The return value of an assignment in Scheme is
unspecified. There are things like
#(set! (hashq-ref x y) z)
that somewhat inscrutably return an actual value other than
*unspecified*. For that reason, # expressions in contexts where
assignments are allowed are evaluated and ignored. Use $ if you want
them to be heeded.
--
David Kastrup