lilypond-user
[Top][All Lists]
Advanced

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

Re: Spacing grobs with an invisible object between them (hack)


From: Aaron Hill
Subject: Re: Spacing grobs with an invisible object between them (hack)
Date: Thu, 06 Feb 2020 07:41:49 -0800
User-agent: Roundcube Webmail/1.4.2

On 2020-02-06 6:10 am, Paolo Prete wrote:
(code)

A few comments on the code:

1) "begin" is used to specify multiple expressions in a construct that only accepts one. "if" would be an example where "begin" could be useful; but "let", like many other constructs, already accepts a list of expressions to evaluate.

;;;;
(define (foo a)
  (let ((b (1+ a)))
    (begin
      (do-something a)
      (do-something b))))

;; ...would become...

(define (foo a)
  (let ((b (1+ a)))
    (do-something a)
    (do-something b)))
;;;;


2) "let" without any bindings would be superfluous syntax.

;;;;
(define (foo a)
  (let ()
    (do-something a)))

;; ...would become...

(define (foo a)
  (do-something a))
;;;;


3) "cond" is best used when there are more than two paths, otherwise "if" is more concise.

;;;;
(define (foo a)
  (cond ((< 0 a) (do-something a))
        (else (do-another-thing a))))

;; ...would become...

(define (foo a)
  (if (< 0 a) (do-something a)
              (do-another-thing a)))
;;;;


4) ly:dir? and symbol-list? are built-in type predicates useful for directions and grob paths, respectively. These can replace your current use of strings as inputs, which eliminates some potentially unsightly quotation marks in the user code.


5) Event functions let the user specify direction with the normal syntax (^, -, _), potentially obviating the need for a direction argument:

%%%%
\version "2.19.83"
foo = #(define-event-function (color) (color?)
  #{ -\tweak color #color -\markup "foo" #})
{ b'4 ^\foo #red b'4 _\foo #blue }
%%%%


-- Aaron Hill



reply via email to

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