On Thu, Jun 7, 2012 at 12:24 PM, <lilypond-user-requ...@gnu.org> wrote: > Joseph Rushton Wakeling <joseph.wakel...@webdrake.net> writes: >> I've also included a few of D's safety features with assert() commands >> to ensure that the variables have the properties required. >> >> ////////////////////////////////////////////////////////////////// >> struct LilyPitch >> { >> int octave; >> int notename; > > What is an int? Why do I need these lines?
Quite an amusing exercise, demolishing the D example. I have half a mind to do the same thing with the original scheme example, but I expect I'll get bored with it about halfway through. Nonetheless, to start off: (define (naturalize-pitch p) (let ((o (ly:pitch-octave p)) (a (* 4 (ly:pitch-alteration p))) ;; alteration, a, in quarter tone steps, ;; for historical reasons (n (ly:pitch-notename p))) For starters, I'm already lost. It's next to impossible, without at least months of practice working with LISP or scheme, to have a strong intuitive sense of which ( and ) belong together (at least, without an editor like emacs that highlights matching brackets). It's very easy for the experienced schemer to underestimate the difficulty this poses -- even to programmers who are experienced in other languages (let alone the novice programmers that all of this is supposed to invite into the world of extending LilyPond). Second: *Prefix* notation for math and comparison operations? This is supposed to be easier for the novice? D is obviously the wrong fit for an lp extension language, but scheme has a couple of strikes against it right from the start. (cond ((and (> a 1) (or (eq? n 6) (eq? n 2))) (set! a (- a 2)) (set! n (+ n 1))) If it's fair to nitpick about D's "pure," "auto," +=, -=, semicolons before braces etc., then it's fair to nitpick about ? and ! here. Reading it, I can sort of understand why, but learning to write it... just one more detail to remember. And, why (cond...) in some places and (if...) in others? (If that's a stupid question, it's no less stupid than some of the other swipes at D.) And I was right... I did get bored with it. But that's because it's kind of pointless. More useful, maybe, would be to compare lp's scheme functions against a comparable implementation in, say, Lua (which is designed for extension-writing). For the record, I'm no apologist for D (I don't know anything about it and it looks rather fussy at first glance, not interesting to me). But scheme is superficially less than appealing as well. I'd say supercollider is more legible (though obviously the sc interpreter isn't a good candidate to integrate into another environment). hjh -- James Harkins /// dewdrop world jamshar...@dewdrop-world.net http://www.dewdrop-world.net "Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman blog: http://www.dewdrop-world.net/words audio clips: http://www.dewdrop-world.net/audio more audio: http://soundcloud.com/dewdrop_world/tracks _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user