[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: my display function
From: |
Mattes |
Subject: |
Re: my display function |
Date: |
Sat, 24 Jan 2015 18:41:58 +0100 |
User-agent: |
SOGoMail 2.2.9a |
Am Samstag, 24. Januar 2015 18:18 CET, "address@hidden" <address@hidden>
schrieb:
> I want to create my own display function that combines several commands
> into one function.
>
> I have tried this
>
> \version "2.19.15"
>
> #(define bar #f)
> #(define tmp #f)
>
> meDisplay =
> #(define-void-function (parser location message value)
> (markup? variable?)
> (display message)
> (display " : ")
> (display value)
> (newline)
> )
>
> foo =
> #(define-void-function (parser location mus)
> (ly:music?)
> (set! tmp (cons #{ b #} #{ cis #}))
> (meDisplay "tmp" tmp)
> (newline)
> (set! bar (acons 1 tmp bar))
> (display bar)
> (newline)
> (set! tmp (cons #{ cis #} #{ b #}))
> (display tmp)
> (newline)
> (set! bar (acons 2 tmp bar))
> (display bar)
> (newline)
> mus
> )
>
> {
> \foo c'
> }
>
> But I get this error:
> Parsing...c:/users/ame/appdata/local/temp/frescobaldi-a77ofr/tmpe2f6wv/document.ly:19:6:
> In expression (meTrace "tmp" tmp):
> c:/users/ame/appdata/local/temp/frescobaldi-a77ofr/tmpe2f6wv/document.ly:19:6:
> Wrong type to apply: #<Music function #<procedure #f (parser location
> message value)>>
> Exited with return code 1.
>
> I'm probably doing a simple error(?) Like having the wrong type of
> define-???-function.
Yes, you declare meDisplay as taking four arguments but call it with two.
Why don't you define it as a simple scheme function?
#(define (meDisplay message value)
(display message)
(display " : ")
(display value)
(newline))
Why do you declare foo as a void function? After all, it _does_ return music,
doesn't it?
foo =
#(define-music-function (parser location mus)
(ly:music?)
(set! tmp (cons #{ b #} #{ cis #}))
(meDisplay "tmp" tmp)
(newline)
(set! bar (acons 1 tmp bar))
(display bar)
(newline)
(set! tmp (cons #{ cis #} #{ b #}))
(display tmp)
(newline)
(set! bar (acons 2 tmp bar))
(display bar)
(newline)
mus)
> I have tried a couple of different type of
> functions but ...
If you do it like above everything should work.
HTH Ralf Mattes
> // Anders
> --
> English isn't my first language.
> So any error or strangeness is due to the translation.
> Please correct my English so that I may become better.
>
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user