"Omid Mo'menzadeh" <omid.mnza...@gmail.com> writes: > Of course!I just attached two files that demonstrate the difference. > > On Sat, Oct 2, 2021 at 3:30 PM David Kastrup <d...@gnu.org> wrote: > >> "Omid Mo'menzadeh" <omid.mnza...@gmail.com> writes: >> >> > I didn't know about $ at all! Where in the documentation can I find more >> > about it? It was hard to search for! >> > >> > I tried it, but it doesn't seem to find my variable "vocal" defined in >> the >> > same .ily file. I tried using #(top-repl) and $(top-repl) too, in the # >> > version it knows what \vocal is, but in the $ version it doesn't. >> >> How about a minimal example exhibiting the problem? >> >> -- >> David Kastrup >> > > \version "2.22.1" > > vocal = \relative c'' { > a4 b c d | > } > > $(if (not (defined? 'is-loaded-file)) #{ \score { \vocal } #})
Well, that one's a timing problem. You couldn't write vocal = \relative c'' { a4 b c d | } \vocal either. The reason is that the assignment is not complete before LilyPond has a chance to check whether something like \addlyrics { Ah } follows, and so when it looks at the next thing that comes up to make that decision, \vocal is not yet defined. So there really needs to be anything after that assignment that does not immediately reference \vocal . With #, LilyPond does not allow different syntactic functionality, so when it sees # it does not bother evaluating it until after it has completed the assignment, being sure that it won't have to add something like \addlyrics ... to the expression to be assigned. This is one case where minimal examples tend to fail more often than actual use of assigned variables in practice, because usually when you employ variables seriously, you don't reference them immediately right afterwards. -- David Kastrup