lilypond-user
[Top][All Lists]
Advanced

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

Re: scheme function help


From: Stjepan Horvat
Subject: Re: scheme function help
Date: Mon, 6 May 2013 22:32:07 +0200

Madoka..you are right..i'm trying to learn Scheme by writing simple functions..i have many ideas about what i would want to achieve..for example..\mark \default is a cool feature because it is never in wrong order..but when it is inside a bar i would want it to have a "," under it..so now i'm trying to understand how lilypond works in combination with scheme..and i did start to learn scheme so i could improve in lilypond..
and now i understand that \breathe looks like (make-music (quote BreathingEvent)) and that \mark \default look like (make-music 'MarkEvent 'label '()) and that '() is the default value..but i'm still one step away of being abel to combine it in a function..but i think that i am one step ahead that i was yesterday..

If i did get it right..to write a function i first write some standard lilypond code how i would want it to look..use displayMusic to see how it should look and than try to simulate it in scheme..

and i imagine where if statment could come in..

btw. i use web gmail and dwb..it was my failure copying madokas code into vim..


On Mon, May 6, 2013 at 7:42 PM, David Kastrup <address@hidden> wrote:
Madoka Machitani <address@hidden> writes:

> On Mon, May 6, 2013 at 10:59 PM, David Kastrup <address@hidden> wrote:
> [...]
>
>     In general, your approach is fundamentally flawed: it is very bad
>     idea
>     to write code relying on user-specified music to be of a
>     particular type
>     (in this case, SequentialMusic) without verifying it. [...]
>
> I think he is just struggling to lern Scheme now by writing simple
> functions,
> and won't understand such technical terms you provided. Also, the one
> who initially wrote flawed sample code (knowingly, to avoid
> complexity) is me.

But you did not avoid complexity.  Even when not using #{ #}, how is

insMark =
#(define-music-function (parser location mark mus)
   (markup? ly:music?)
   (set! (ly:music-property mus 'elements)
         (cons (make-music 'MarkEvent 'label mark)
               (ly:music-property mus 'elements)))
   mus)

supposed to be less complex than

insMark =
#(define-music-function (parser location mark mus)
   (markup? ly:music?)
   (make-sequential-music
     (list (make-music 'MarkEvent 'label mark) mus)))

?  Actually, it might be worth mentioning that the above is _worse_ than

insMark =
#(define-music-function (parser location mark mus)
   (markup? ly:music?)
   #{ \mark #mark #mus #})

because it works worse with point&click.  You should at least do

insMark =
#(define-music-function (parser location mark mus)
   (markup? ly:music?)
   (make-sequential-music
     (list (make-music 'MarkEvent 'label mark 'origin location) mus)))

to get the same usability as the #{...#} version.

--
David Kastrup


_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user



--
Nesmotren govori kao da mačem probada, a jezik je mudrih iscjeljenje. Izreke 12:18

reply via email to

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