• Willkommen im Forum „Archiviertes Lilypond Forum (2017)“.
 

Dies ist das Archiv des alten Forums (bis März 2017). Das aktuelle Forum ist unter lilypondforum.de zu finden.
This is the archive of the old forum (until March 2017). You can find the current forum at lilypondforum.de.

Hauptmenü

Scheme Syntax

Begonnen von rJazz, Mittwoch, 14. Oktober 2015, 17:43

Vorheriges Thema - Nächstes Thema

rJazz

Hallo,
ich scheitere bei Scheme im Moment noch an  der Befehlsverkettung:


\version "2.19.27"
# (define a 204) 
#(display a)

#( (define b 124)  (display b))
 


die Ausgabe von a und b funktionieren,
ich bekommen aber (für den Teil für b)
einen Syntaxfehler:

Zitat
Parsing...
/home/std/Dokumente/python/lilypond/scheme_test.ly:5:2: error: GUILE signaled an error for the expression beginning here
#
( (define b 124)  (display b))
204124
Wrong type to apply: #<unspecified>
fatal error: failed files: "/home/std/Dokumente/python/lilypond/scheme_test.ly"
 

Werden Befehle nicht wie Listenelemente verkettet?

harm6

Aus dem guile-manual:

Zitat
— Scheme Syntax: define name value

    Create a top level variable named name with value value. If the named variable already exists, just change its value. The return value of a define expression is unspecified.
(Fettdruck von mir)

D.h. in der Liste:
    ( (define b 124)  (display b))
ist der erste Ausduck unspecified.
Insoweit weiß guile nicht was es mit dieser Liste auf sich hat und gibt einen error aus:  Wrong type to apply: #<unspecified>

Tatsächlich könntest Du
  (begin (define b 124)  (display b))
kodieren. Ist aber befremdlich.

Besser:

(let ((b 124))
  (display b))


oder

((lambda (b)
  (display b)) 124


Siehe auch:
http://lilypondblog.org/2014/05/local-variables-in-scheme-lilypond/


HTH,
  Harm





rJazz

Wow, das ist nicht trivial.  :D
Danke!

harm6

Eine weitere Syntaxmöglichkeit:
(let ()
  (define b 124)
  (display b))


Gruß.
  Harm

fugenkomponist

Dann aber doch lieber begin, oder? Oder gibts da einen semantischen Unterschied?