添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
[ << Interfaces for programmers ][ Top ][ Contents ][ Index ][ LilyPond Scheme interfaces >> ] [ < Scheme function usage ][ Up : Scheme functions ][ ]

2.2.3 Void scheme functions

Sometimes a procedure is executed in order to perform an action rather than return a value. Some programming languages (like C and Scheme) use functions for either concept and just discard the returned value (usually by allowing any expression to act as statement, ignoring the result). This is clever but error-prone: most C compilers nowadays offer warnings for various non-“void” expressions being discarded. For many functions executing an action, the Scheme standards declare the return value to be unspecified. LilyPond’s Scheme interpreter Guile has a unique value *unspecified* that it usually (such when using set! directly on a variable) but unfortunately not consistently returns in such cases.

Defining a LilyPond function with define-void-function makes sure that this special value (the only value satisfying the predicate void? ) will be returned.

noPointAndClick =
#(define-void-function
   (ly:set-option 'point-and-click #f))
\noPointAndClick   % disable point and click

If you want to evaluate an expression only for its side-effect and don’t want any value it may return interpreted, you can do so by prefixing it with \void:

\void #(hashq-set! some-table some-key some-value)

That way, you can be sure that LilyPond will not assign meaning to the returned value regardless of where it encounters it. This will also work for music functions such as \displayMusic. [ << Interfaces for programmers ][Top][Contents][Index][ LilyPond Scheme interfaces >> ] [ < Scheme function usage ][ Up : Scheme functions ][] This page is for LilyPond-2.23.82 (development-branch). We welcome your aid; please help us by reporting errors to our bug list. Other languages: Deutsch, Español, Français. About automatic language selection.

  • 1.2.3 Debugging Scheme code
  • 1.2.4 Input variables and Scheme
  • 1.2.5 Importing Scheme in LilyPond
  • 1.2.6 Object properties
  • 1.2.7 LilyPond compound variables
  • Offsets
  • Fractions
  • Extents
  • Property alists
  • Alist chains
  • 1.2.8 Internal music representation
  • 1.3 Building complicated functions
  • 1.3.1 Displaying music expressions
  • 1.3.2 Music properties
  • 1.3.3 Doubling a note with slurs (example)
  • 1.3.4 Adding articulation to notes (example)
  • 2. Interfaces for programmers
  • 2.1 LilyPond code blocks
  • 2.2 Scheme functions
  • 2.2.1 Scheme function definitions
  • 2.2.2 Scheme function usage
  • 2.2.3 Void scheme functions
  • 2.3 Music functions
  • 2.3.1 Music function definitions
  • 2.3.2 Music function usage
  • 2.3.3 Simple substitution functions
  • 2.3.4 Intermediate substitution functions
  • 2.3.5 Mathematics in functions
  • 2.3.6 Functions without arguments
  • 2.3.7 Void music functions
  • 2.4 Event functions
  • 2.5 Markup functions
  • 2.5.1 Markup construction in Scheme
  • 2.5.2 How markups work internally
  • 2.5.3 New markup command definition
  • Markup command definition syntax
  • On properties
  • A complete example
  • Adapting builtin commands
  • Converting markups to strings
  • 2.5.4 New markup list command definition
  • 2.6 Contexts for programmers
  • 2.6.1 Context evaluation
  • 2.6.2 Running a function on all layout objects
  • 2.7 Callback functions
  • 2.8 Unpure-pure containers
  • 2.9 Difficult tweaks
  • 3. LilyPond Scheme interfaces
  • A. GNU Free Documentation License
  • B. LilyPond index
  •