lilypond-user
[Top][All Lists]
Advanced

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

Re: help with Wrong type of argument


From: Lukas-Fabian Moser
Subject: Re: help with Wrong type of argument
Date: Mon, 1 May 2023 12:52:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1

Hi Michael,

To say I'm no expert in Scheme is a vast understatement. However, I think I found the answer to this one.
Just in order to reassure you a bit:

 Basically, as I understand things, this bit:
 
       #'((lineto 0 hgt)

Accosrding to my rather vague understanding of Scheme syntax the ' between the # and the 1st ( is saying don't interpret anything in that _expression_, just pass it as is. Which means that your variable hgt isn't getting passed as a variable but is getting passed as simply a series of three characters.
Better make that: hgt is passed as the "symbol" hgt (usually entered as 'hgt in Scheme). Other than that, you're right.
What seems to be needed (and what made this appear to work here) is to use what's called quasiquoting. Basically, it lets you designate certain bits within an _expression_ as "this part should be interpreted before getting passed on". This entails changing the above line to:

#`((lineto 0 ,hgt)

By changing the ' into a ` (BTW, that's the one that on my keyboard is up near the top left, just under the Escape key) you say that there's something in the following _expression_ that will need interpreted. Then the comma before the variable name points out which item to interpret.

That's correct (modulo the term "interpret" where "evaluate" is more common), and quasiquoting indeed is the right way to construct complicated list/pair structures containing lots of symbols and some variables that should be evaluated.

There's one other way which is sometimes useful (but admittedly won't simplify the present use case much):

#`((lineto 0 ,hgt) (closepath))

is the a list with two elements, namely
- the 3-element list containing 'lineto, 0 and the value of the variable hgt
- the 1-element list containing the symbol 'closepath.

This may also be written as:

#(list (list 'lineto 0 hgt) (list 'closepath))

or, mixing the two styles,

#(list (list 'lineto 0 hgt) '(closepath))

Lukas


reply via email to

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