On Mon 04 Apr 2016 at 12:46:37 (+0200), Bernard wrote: > On 03-04-16 22:56, David Kastrup wrote: > >Bernard <lilyp...@bernardhulsman.nl> writes: > >>That does help. I found out \with is a very special statement. > >Not really. \with can be part of other constructs, just like "else" can > >be part of other constructs in many programming languages (including > >Scheme). It is not a "statement" at all. > That does help a lot. Now I understand why there can not be anything > before /with. > > > >>It influence what happens before the statement, it must be executed > >>just after \new . That is the reason why my examples 4 and 5 did not > >>work. > >>And it influence what happens after the statement. If within the Staff > >>not a additional Staff property can be set. > >> > >>No wonder it confuses me. > >\with introduces "context modifications". They are basic expressions in > >that they can be stored in variables and passed to functions, but to > >take effect, they need to be applied to an actually created context, and > >there are various syntactic constructs for doing that. > > > >They "influence what happens after the statement" like any modification > >to anything. Their influence is restricted to contexts they are applied > >to (possibly via layout or context definitions or wrapped into other > >context modifications). > > > I still do not get it all. By the way, I am my self a Python > programmer and object orientation in known to me.
[...] Your example is incomprehensible to me as I've never used drum mode. It's also large enough to obfuscate the problem. Simplifying the code: %%%%%%%%%% mus = { e' f' g' a' } \markup { with section } \score { \new Staff \with { \override NoteHead.color = #red } \mus } \markup { with section } \score { \new Staff \with { \override NoteHead.color = #red } { e' f' g' a' } } %% That worked. The \with { xxx } modified the music. %% Then you took out the \with so the { xxx } now becomes the music. %% (Music expressions can include context modifications as well as notes.) %% Think of python's positional parameters and keyword parameters. %% You start with ( keyword=argument, parm ) but you remove "keyword=" %% so you're left with ( argument, parm ) and "argument" becomes a %% positional parameter instead. %% In LilyPond, the "first positional parameter" is the music. %% Most LilyPond elements consist of either \element SINGLE-value %% or \element { SINGLE arbitrarily complicated expression } %% and not \element { argument } { parm } %% So LilyPond does not allow a "second positional parameter". \markup { without the use of the with section } %% generate error \score { \new Staff { \override NoteHead.color = #red } \mus } \markup { without the use of the with section } %% generate error \score { \new Staff { \override NoteHead.color = #red } { e' f' g' a' } } %% Your music now becomes treated as illegal source code because %% it's syntactically a "second positional parameter". %% However, if you move the music in with the "first positional parameter": \markup { without the use of the with section } \score { \new Staff { \override NoteHead.color = #red \mus } } \markup { without the use of the with section } \score { \new Staff { \override NoteHead.color = #red e' f' g' a' } } \markup { without the use of the with section } \score { \new Staff { e' f' \override NoteHead.color = #red g' a' } } %%%%%%%%%% If you really want a python example; when you "skipped the with section" by deleting "\with" what you did was like changing: with fileinput.input(args, mode='rb') as theinput: for bytestring in theinput: nbytesscanned += len(bytestring) linenum += 1 for k in bytestring: maxchar = max(maxchar, k) if k not in firsts: firsts[k] = linenum counts[k] = counts.setdefault(k,0) + 1 into: fileinput.input(args, mode='rb') as theinput: for bytestring in theinput: nbytesscanned += len(bytestring) linenum += 1 for k in bytestring: maxchar = max(maxchar, k) if k not in firsts: firsts[k] = linenum counts[k] = counts.setdefault(k,0) + 1 Python now has no idea what to do with the word "as". Cheers, David. _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user