"R. Mattes" <r...@mh-freiburg.de> writes:

> Dear list,
>
> I just stumbled over a strange problem. I'm trying to use some of
> my guile code from within Lilypond. When trying to import some of
> my macros (when and unless) into Lilypond I get the following error:
>
> ,---- LilyPond RELP ---------------------------------
> | guile> (load "syntactic-shugar.scm")
> | <unnamed port>: In expression (void):
> | <unnamed port>: Wrong type to apply: #<Music function #<procedure #f (parser
> location arg)>>
> | ABORT: (misc-error)
> `----
>
> Here ias the code:
>
> ,---- file syntactic-shugar.scm ---------------------
> | (use-syntax (ice-9 syncase))
> |
> | (define-syntax when
> |   (syntax-rules ()
> |     ((when condition expression ...)
> |      (if condition (begin expression ...)))))
> |
> | (define-syntax unless
> |   (syntax-rules ()
> |     ((unless condition expression ...)
> |      (if (not condition) (begin expression ...)))))
> `----
>
> The same code works without problems in guile itself.
>
> Lilypond version: "2.19.5"
> Guile version: "1.8.8"
>
> Any idea what's going on?

Yes.  LilyPond defines a music function \void, and (ice-9 syncase) gets
confused by that for whatever stupid reason (the bug is reported, but
don't expect any 1.8 releases any more).  Guile 2.0 works but of course
that is of little consolation.  I think there are command line options
for "preloading" some Scheme files: those might work before \void gets
defined.

Other than that, you can put
(define-module (scm syntactic-shugar) #:use-syntax (ice-9 syncase)
  #:export-syntax (when unless))

at the top of your file, and

(use-modules (scm syntactic-shugar))

after loading it.

Basically, keep syncase from seeing the LilyPond main module when
loading it.

-- 
David Kastrup

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to