You need to call your function either like this
\disdn 8
or like this
\disdn #(ly:make-duration 3)
When you write #8
you tell Lilypond to use the guile object 8
, which is a number. But if you write 8
the parser will try to properly interpret this and will interpret this as duration.
For your code to work though you’d need to write
disdn =
#(define-music-function
(d)
(ly:duration?)
#{
<dis ais dis g>$d
#})
Check the documentation for the difference between #
and $
: https://lilypond.org/doc/v2.24/Documentation/extending/lilypond-scheme-syntax
Basically #
will mean the expression is lexed and then evaluated later by the parser. Meanwhile $
will mean that the expression is evaluated while it is being lexed, and the parser will parse the already evaluated expression. So writing
<...>#d
the parser will see <...>
followed by a scheme expression and thus first evaluates <...>
with the previous duration and then evaluates the scheme expression. But if you do
<dis ais dis g>$d
the parser will see <...>
followed by a duration, and will thus evaluate this with the given duration.