lilypond-user
[Top][All Lists]
Advanced

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

Re: guitar scale diagram - change root


From: David Kastrup
Subject: Re: guitar scale diagram - change root
Date: Thu, 01 Sep 2016 21:16:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

bart deruyter <address@hidden> writes:

> #(define-markup-command (scale-diagramm layout props arg1 arg2 start arg3
> arg4) (list? integer? integer? number? integer?)
>
> (interpret-markup layout props
>
>     (markup
>
>      (#:override (cons 'size arg3 )
>
> (#:override '(fret-diagram-details
>                     . (
>                        (finger-code . in-dot)
>                        (number-type . arabic)
>                        (label-dir   . -1)
>                        (orientation . landscape)
>                        (dot-radius  . 0.4)
>                        (fret-count . arg4 )
>                        (top-fret-thickness . 4)))
>          #:fret-diagram-verbose
>         (fret-from-list arg1 '() arg2 start ))))))
>
> but then I get this error:
>
> Preprocessing graphical objects...fret-diagrams.scm <0>: In procedure > in
> expression (> maxfret my-fret-count):
>
> fret-diagrams.scm <1>: Wrong type argument in position 2: arg4
>
>
> Clearly it's an issue of 'type argument'. When I change fret-count to the
> actual integer 12 instead of the variable arg4, it works. It is probably
> something schemy I don't get...

arg4 is a symbol in a quoted list, just like landscape, arabic, in-dot
are.  If you replace the quote ' after #:override with a "quasiquote",
namely the backward tick ` then you can "unquote" inside of the
expression by preceding something with , the unquote character.  When
an expression is unquoted, it is evaluated as normal and placed in the
quoted list.  So you'd have
(#:override `(fret-diagram-details
                  [...]
                  (fret-count . ,arg4)
                  [...]

Lisp (and Scheme) do not actually have a program syntax.  Instead you
enter the parse tree as a data structure, a nested list.  Every start of
a list is a function call, every symbol is looked up as a variable
(functions are just special variable values) and the remaining list
elements are the argument of the function call, evaluated before
calling.  Or, in case we are talking about a macro (or special form)
instead of a function, passed unevaluated to the macro and the result of
the macro call is then evaluated.

That sounds awfully complex, but that's all there is to Scheme program
structure.  The only "syntax" you have to deal with is actually for data
entry, most of which consists of lists.

Once you realise that Scheme does not have a program syntax, just a
program _structure_ and that the syntax is only for data entry, it
becomes obvious
a) why Scheme feels so different from other languages
b) why it is so great for macro/program manipulation

-- 
David Kastrup



reply via email to

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