Discussion:
Problem compiling: music-functions-init.ly
Keizen Li Qian
2018-11-14 04:53:07 UTC
Permalink
Hello again, I did a clean install of 2.18.2 in Ubuntu and am getting the
error below when I compile. I checked the script against the sourceforge
files and was wondering if anyone has any suggestions for compiling. I
would appreciate detailed instructions.

Thank you in advance!

$ lilypond document.ly
GNU LilyPond 2.18.2
Processing `document.ly'
Parsing.../usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: In
procedure ly:music-transpose in expression (ly:music-transpose (make-music
# # ...) tonic):
/usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: Wrong type
(expecting pair): major

Keizen
Urs Liska
2018-11-14 07:42:27 UTC
Permalink
Post by Keizen Li Qian
Hello again, I did a clean install of 2.18.2 in Ubuntu and am getting the
error below when I compile. I checked the script against the
sourceforge
files and was wondering if anyone has any suggestions for compiling. I
would appreciate detailed instructions.
Thank you in advance!
$ lilypond document.ly
GNU LilyPond 2.18.2
Processing `document.ly'
Parsing.../usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: In
procedure ly:music-transpose in expression (ly:music-transpose
(make-music
/usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: Wrong type
(expecting pair): major
This is a complaint about something in your document, so we'd need to see that.

Urs
Post by Keizen Li Qian
Keizen
Davide Liessi
2018-11-14 08:42:06 UTC
Permalink
Il giorno mer 14 nov 2018 alle ore 08:25 Keizen Li Qian
/usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: Wrong type (expecting pair): major
You probably wrote
\key c major
instead of
\key c \major

Davide
David Kastrup
2018-11-14 09:06:40 UTC
Permalink
Post by Davide Liessi
Il giorno mer 14 nov 2018 alle ore 08:25 Keizen Li Qian
In procedure ly:music-transpose in expression (ly:music-transpose
/usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: Wrong
type (expecting pair): major
\key c major
instead of
\key c \major
Well spotted. The embarrassing thing is that we even get there: this
is something that should rather be caught earlier. We have

key =
#(define-music-function (tonic pitch-alist)
((ly:pitch? '()) (list? '()))
[...]

and the word major qualifies as list? by getting converted to '(major)
which is a symbol list like needed for some override/tweak
specifications.

So it very much looks like we should use a more specific predicate than
list? for the scale type in order to not have that user error pass down
in this manner.

Suggestions?
--
David Kastrup
David Kastrup
2018-11-14 09:27:35 UTC
Permalink
Post by David Kastrup
Post by Davide Liessi
Il giorno mer 14 nov 2018 alle ore 08:25 Keizen Li Qian
In procedure ly:music-transpose in expression (ly:music-transpose
/usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: Wrong
type (expecting pair): major
\key c major
instead of
\key c \major
Well spotted. The embarrassing thing is that we even get there: this
is something that should rather be caught earlier. We have
key =
#(define-music-function (tonic pitch-alist)
((ly:pitch? '()) (list? '()))
[...]
and the word major qualifies as list? by getting converted to '(major)
which is a symbol list like needed for some override/tweak
specifications.
So it very much looks like we should use a more specific predicate than
list? for the scale type in order to not have that user error pass down
in this manner.
Suggestions?
Well, I can bump that rather easily (using existing predicates) to


gag.ly:2:10: error: wrong type for argument 2. Expecting list of number pairs, found "major"
\key c
major

This is probably at best slightly less obscure to the beginner but at
least flags the right place and element in the input. To give a nicer
message, one would need a specific predicate for scales.
--
David Kastrup
Thomas Morley
2018-11-14 09:53:27 UTC
Permalink
Post by David Kastrup
Post by David Kastrup
Post by Davide Liessi
Il giorno mer 14 nov 2018 alle ore 08:25 Keizen Li Qian
In procedure ly:music-transpose in expression (ly:music-transpose
/usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: Wrong
type (expecting pair): major
\key c major
instead of
\key c \major
Well spotted. The embarrassing thing is that we even get there: this
is something that should rather be caught earlier. We have
key =
#(define-music-function (tonic pitch-alist)
((ly:pitch? '()) (list? '()))
[...]
and the word major qualifies as list? by getting converted to '(major)
which is a symbol list like needed for some override/tweak
specifications.
So it very much looks like we should use a more specific predicate than
list? for the scale type in order to not have that user error pass down
in this manner.
Suggestions?
Well, I can bump that rather easily (using existing predicates) to
gag.ly:2:10: error: wrong type for argument 2. Expecting list of number pairs, found "major"
\key c
major
This is probably at best slightly less obscure to the beginner but at
least flags the right place and element in the input. To give a nicer
message, one would need a specific predicate for scales.
--
David Kastrup
_______________________________________________
lilypond-user mailing list
https://lists.gnu.org/mailman/listinfo/lilypond-user
I'm not convinced about below, but for the record:

One could give the key-function a string-argument, or probably a symbol
And react on the input, like

(case <input>
(("major") major)
...
(else (ly:error/warning "message"))

Obviously pseudo-code (I'm in a hurry), but I hope the proposal is made clear.
Also, would need a convert-rule.

Cheers,
Harm
Urs Liska
2018-11-14 10:01:23 UTC
Permalink
Post by Thomas Morley
Post by David Kastrup
Post by David Kastrup
Post by Davide Liessi
Il giorno mer 14 nov 2018 alle ore 08:25 Keizen Li Qian
In procedure ly:music-transpose in expression (ly:music-transpose
/usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: Wrong
type (expecting pair): major
\key c major
instead of
\key c \major
Well spotted. The embarrassing thing is that we even get there: this
is something that should rather be caught earlier. We have
key =
#(define-music-function (tonic pitch-alist)
((ly:pitch? '()) (list? '()))
[...]
and the word major qualifies as list? by getting converted to '(major)
which is a symbol list like needed for some override/tweak
specifications.
So it very much looks like we should use a more specific predicate than
list? for the scale type in order to not have that user error pass down
in this manner.
Suggestions?
Well, I can bump that rather easily (using existing predicates) to
gag.ly:2:10: error: wrong type for argument 2. Expecting list of number pairs, found "major"
\key c
major
This is probably at best slightly less obscure to the beginner but at
least flags the right place and element in the input. To give a nicer
message, one would need a specific predicate for scales.
--
David Kastrup
_______________________________________________
lilypond-user mailing list
https://lists.gnu.org/mailman/listinfo/lilypond-user
One could give the key-function a string-argument, or probably a symbol
And react on the input, like
(case <input>
(("major") major)
...
(else (ly:error/warning "message"))
Obviously pseudo-code (I'm in a hurry), but I hope the proposal is made clear.
Also, would need a convert-rule.
I don't think this would be the right direction. We don't want to
prevent the user from entering "major" but prevent arbitrary
symbols/strings to be implicitly converted to a list. Users can pass
scale definitions beyond the known \major \minor.

Urs
Post by Thomas Morley
Cheers,
Harm
_______________________________________________
lilypond-user mailing list
https://lists.gnu.org/mailman/listinfo/lilypond-user
David Kastrup
2018-11-14 10:03:32 UTC
Permalink
Post by Thomas Morley
One could give the key-function a string-argument, or probably a symbol
And react on the input, like
(case <input>
(("major") major)
...
(else (ly:error/warning "message"))
Obviously pseudo-code (I'm in a hurry), but I hope the proposal is made clear.
Also, would need a convert-rule.
That would leave us with the same situation we had for a long time
regarding engravers: the built-in scales would be a privileged class and
you'd need to have some registration mechanism to elevate user-defined
scales.

I usually lean towards making things work "as expected" but I don't
really think it would be doing us favors here.
--
David Kastrup
Thomas Morley
2018-11-14 10:09:14 UTC
Permalink
Post by David Kastrup
Post by Thomas Morley
One could give the key-function a string-argument, or probably a symbol
And react on the input, like
(case <input>
(("major") major)
...
(else (ly:error/warning "message"))
Obviously pseudo-code (I'm in a hurry), but I hope the proposal is made clear.
Also, would need a convert-rule.
That would leave us with the same situation we had for a long time
regarding engravers: the built-in scales would be a privileged class and
you'd need to have some registration mechanism to elevate user-defined
scales.
I usually lean towards making things work "as expected" but I don't
really think it would be doing us favors here.
--
David Kastrup
As said, I'm not convinced about this myself, but I thought the (at
least) thinkable alternative should have been discussed.
This happened now. ;)

My very first thought about the problem was to use number-pair-list?
So I'm fine with your patch.

Cheers,
Harm
David Kastrup
2018-11-14 14:19:17 UTC
Permalink
Thanks for working on this. Please let me know when and how to get it.
It was probably less than clear from this discussion: your problem is
user error. It will remain user error LilyPond refuses to compile, but
the error message will be better after the change.

You need to write \key c \major instead of \key c major : note the
additional backslash.
--
David Kastrup
David Kastrup
2018-11-14 17:05:56 UTC
Permalink
I need clarification because I did not write the init.ly file or the line
\key c major. Should I root edit the init.ly file as you suggest?
I did not in any way whatsoever suggest editing init.ly or any other
part of LilyPond, and you quite certainly did write a statement of the
kind \key x major in your input file which needs to be rewritten as
\key x \major instead.
--
David Kastrup
Aaron Hill
2018-11-14 22:08:17 UTC
Permalink
I need clarification because I did not write the init.ly file or the
line
\key c major. Should I root edit the init.ly file as you suggest?
Perhaps it would help to clear up things for you to provide us a MWE
(minimal working example) that produces the error message you got. That
is going to be essential for any of us to give you practical advice.

All we know is that the input file (document.ly, not
music-functions-init.ly) contains "major" when it must be written with a
leading backslash as "\major". If you can verify that your input file
does not do this and yet the error message still occurs, then there is
something else going on. At that point, we would definitely need a MWE
to be able to repro the issue.

-- Aaron Hill

Urs Liska
2018-11-14 09:32:13 UTC
Permalink
Post by David Kastrup
Post by Davide Liessi
Il giorno mer 14 nov 2018 alle ore 08:25 Keizen Li Qian
In procedure ly:music-transpose in expression (ly:music-transpose
/usr/share/lilypond/2.18.2/ly/music-functions-init.ly:564:11: Wrong
type (expecting pair): major
\key c major
instead of
\key c \major
Well spotted. The embarrassing thing is that we even get there: this
is something that should rather be caught earlier. We have
key =
#(define-music-function (tonic pitch-alist)
((ly:pitch? '()) (list? '()))
[...]
and the word major qualifies as list? by getting converted to '(major)
which is a symbol list like needed for some override/tweak
specifications.
So it very much looks like we should use a more specific predicate than
list? for the scale type in order to not have that user error pass down
in this manner.
Suggestions?
major and minor are lists with seven number pairs where the cars are
0..6 and the cdrs are 0 or -1/2.

I'm not sure how the definition of custom scales works and how much
freedom the user has to that, but I'd assume that requiring number-pairs
(probably an unspecified number of pairs) with the cars forming a row of
natural numbers should be the right thing.

As you mention in the other post there should be a specific predicate
(why not `pitch-alist?`).

Urs
David Kastrup
2018-11-14 09:48:08 UTC
Permalink
Post by Urs Liska
major and minor are lists with seven number pairs where the cars are
0..6 and the cdrs are 0 or -1/2.
I'm not sure how the definition of custom scales works and how much
freedom the user has to that, but I'd assume that requiring
number-pairs (probably an unspecified number of pairs) with the cars
forming a row of natural numbers should be the right thing.
I am not sure whether sequentiality is an absolute.
Post by Urs Liska
As you mention in the other post there should be a specific predicate
(why not `pitch-alist?`).
For now I did

Tracker issue: 5438 (https://sourceforge.net/p/testlilyissues/issues/5438/)
Rietveld issue: 357840043 (https://codereview.appspot.com/357840043)
Issue description:
Give \key command a better predicate for scale type { \key c
major } should not be accepted at the parsing state, turning
"major" into '(major) matching the list? predicate. So instead a
number-pair-list? predicate is being used which is much less likely
to be matched by erroneous input.

This is certainly better than what we had, and I don't think it's likely
to trigger with accidental input like previously.
--
David Kastrup
Urs Liska
2018-11-14 10:23:33 UTC
Permalink
Post by David Kastrup
Post by Urs Liska
major and minor are lists with seven number pairs where the cars are
0..6 and the cdrs are 0 or -1/2.
I'm not sure how the definition of custom scales works and how much
freedom the user has to that, but I'd assume that requiring
number-pairs (probably an unspecified number of pairs) with the cars
forming a row of natural numbers should be the right thing.
I am not sure whether sequentiality is an absolute.
I just checked a few things:

1) The order of the cars is irrelevant 2) The cars must be exact
integers 3) If the cdr of a scale step is 0 the pair can be left out.

4) If a car is present more than once then a sharp will dominate
regardless of the order in the list.

5) If a car is < 0 or > 6 a warning "warning: Incomplete
keyAlterationOrder for key signature" is produced but the corresponding
alteration is set => (9 . 1/2) will produce a sharp on the third step 6)
I don't know how one can produce scales with more or less than 7 steps
(but I hope this is possible with LilyPond), but I assume that in case
the behaviour is the same except that the range 0..6 will be different.

7) The cdr of a step may be any number for which there's a key in
KeySignature.glyph-name-alist. Otherwise a warning "warning: No glyph
found for alteration: 1/8" is issued
Post by David Kastrup
Post by Urs Liska
As you mention in the other post there should be a specific predicate
(why not `pitch-alist?`).
For now I did
Tracker issue: 5438 (https://sourceforge.net/p/testlilyissues/issues/5438/)
Rietveld issue: 357840043 (https://codereview.appspot.com/357840043)
Give \key command a better predicate for scale type { \key c
major } should not be accepted at the parsing state, turning
"major" into '(major) matching the list? predicate. So instead a
number-pair-list? predicate is being used which is much less likely
to be matched by erroneous input.
This is certainly better than what we had, and I don't think it's likely
to trigger with accidental input like previously.
I think based on my above observations it would be possible to determine
a better predicate than "unlikely to trigger with accidental input".

A key signature mode must

* be a list of number pairs * each car must be an exact integer >= 0 *
each car must occur only once

We can ignore the matching of the cdr I think because the warning is
appropriate and points exactly to the problem.

I'm not sure about the upper range. It's acceptable to ignore the
warning but it feels going in the wrong direction (it's not that the
definition is "incomplete", it's rather an invalid step). If it is
possible to define scales with alternative number of steps it may be
necessary to check that length.

Urs
David Kastrup
2018-11-14 10:35:44 UTC
Permalink
Post by Urs Liska
1) The order of the cars is irrelevant 2) The cars must be exact
integers 3) If the cdr of a scale step is 0 the pair can be left out.
4) If a car is present more than once then a sharp will dominate
regardless of the order in the list.
5) If a car is < 0 or > 6 a warning "warning: Incomplete
keyAlterationOrder for key signature" is produced but the
corresponding alteration is set => (9 . 1/2) will produce a sharp on
the third step 6) I don't know how one can produce scales with more or
less than 7 steps (but I hope this is possible with LilyPond), but I
assume that in case the behaviour is the same except that the range
0..6 will be different.
7) The cdr of a step may be any number for which there's a key in
KeySignature.glyph-name-alist. Otherwise a warning "warning: No glyph
found for alteration: 1/8" is issued
[...]
Post by Urs Liska
I think based on my above observations it would be possible to
determine a better predicate than "unlikely to trigger with accidental
input".
A key signature mode must
* be a list of number pairs * each car must be an exact integer >= 0 *
each car must occur only once
We can ignore the matching of the cdr I think because the warning is
appropriate and points exactly to the problem.
I'm not sure about the upper range. It's acceptable to ignore the
warning but it feels going in the wrong direction (it's not that the
definition is "incomplete", it's rather an invalid step). If it is
possible to define scales with alternative number of steps it may be
necessary to check that length.
I think you are overthinking this. The purpose of predicates in
LilyPond music functions et al is to sort input according to its
intended meaning, not to establish its validity, particularly not for
complex data types. So we have a lot of "number?" predicates where only
exact numbers of a certain type would actually be acceptable.

If you hand-construct something in Scheme that isn't valid but passes
the syntactic check, then it will likely blow up somewhere in LilyPond's
bowels. If you hand-constructed something in Scheme, you are expected
to be able to deal with that. We cannot really move all of the
intelligence into the parser.

So the predicate list? was good enough here (barely, though) until
unrelated changes made it possible to turn the input

major

into a list. Which the parser then dutifully did here.
--
David Kastrup
Loading...