lilypond-devel
[Top][All Lists]
Advanced

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

Re: critical issues


From: David Kastrup
Subject: Re: critical issues
Date: Tue, 03 Jan 2012 22:15:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Janek Warchoł <address@hidden> writes:

> 2012/1/3 David Kastrup <address@hidden>:

>> LilyPond needs to get into a state where, say, half the
>> engravers are written and maintained in Scheme.  And by "Scheme" I don't
>> mean "Scheme at the level Nicolas can barely handle" but "Scheme a
>> Fortran programmer would not have all too much of a problem
>> understanding".
>
> Umm, impossible?  From my perspective, 'Scheme' and 'easy to
> understand' are mutually exclusive.  Unless there are more comments
> than code - literally - but we don't do so.

Well, as an example, take a look at
<URL:http://nicolas.sceaux.free.fr/prelude/prelude.html>

Now take a look at

\begin{lilypond}
ph = #(define-music-function (parser location p1 p2 p3 p4 p5)
       (ly:pitch? ly:pitch? ly:pitch? ly:pitch? ly:pitch?)
       #{
          \repeat unfold 2 { $p1 2 } |
          \repeat unfold 2 { r16 $p2 8. ~ $p2 4 } |
          \repeat unfold 2 { r8 $p3 16 $p4 $p5 $p3 $p4 $p5 } |
       #})  
\parallelMusic #'(low middle high)
{
  \ph c'   e'  g' c'' e''
  R1*7 | \skip 1*7 | R1*7 |
  \ph a    c'  e' g' c''
  \voiceTwo | \change Staff = "down" \voiceOne | \oneVoice |
  \ph d    a   d' fis' c''
  R1*21 | \skip 1*21 | R1*21 |
  \ph c,   c   g bes e'
  c,2~ c, | r16 c8. ~ c4 ~ c2
  | r8 f16 a c' f' c' a c' a f a f d f d |
  c,2~ c, | r16 b,8. ~ b,4 ~ b,2
  | r8 g'16 b' d'' f'' d'' b' d'' b' g' b' d' f' e' d' |
  c,1\fermata | c1 | <e' g' c''>1\fermata \bar "|." |
}
\score {
  \new PianoStaff <<
    \new Staff = "up" {
      << \high \\ \middle >>
    }
    \new Staff = "down" {
      \clef bass
      \low
    }
  >>
  
  \midi {
    \context {
      \Score
      \with \settingsFrom { \tempo 4 = 80 }
    }
  }

  \layout {
    \context {
      \Score
      \with \settingsFrom { \compressFullBarRests }
    }
    \context {
      \Staff
      \with \settingsFrom { \accidentalStyle modern }
    }
  }
}  
\end{lilypond}

\ph is a music function written in Scheme.  Can you understand it?
\settingsFrom is actually returning a Scheme expression for \with to
use.  It makes things rather simpler than more complex, even though it
constitutes a Scheme expression.

Scheme is not hard.  Programming is hard.  And there is still far too
much repetitive programming required for stuff that could be handled
using shrinkwrapped tools (\settingsFrom is such a tool) if anybody had
bothered packaging them.  Far too often if I think "Ok, task x has no
documented way of dealing with it.  Let's see whether we can find an
undocumented API".  And then I find about 10 files implementing their
own ad hoc API that will break in different ways if one has to change
the data structures at some point of time.

-- 
David Kastrup




reply via email to

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