[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Strange error from define-syntax
From: |
John Schlomann |
Subject: |
RE: Strange error from define-syntax |
Date: |
Thu, 28 May 2020 12:17:45 -0500 |
Thank you, David, for your quick response. I'm not sure what you mean by
"stick to macros". I thought define-syntax was the way to define a macro.
What am I missing?
John
> -----Original Message-----
> From: David Kastrup [mailto:dak@gnu.org]
> Sent: Thursday, May 28, 2020 11:54 AM
> To: John Schlomann
> Cc: 'Lilypond-User Mailing List'
> Subject: Re: Strange error from define-syntax
>
> "John Schlomann" <jschlomann@wideopenwest.com> writes:
>
> > Dear Ponders & Schemers,
> >
> >
> >
> > I wanted to try creating a simple Scheme macro. I've never done this
> before,
> > so I may well be going about it all wrong, but the error I get doesn't
make
> > sense.
> >
> >
> >
> > Here is a minimal non-working example:
> >
> >
> >
> > \version "2.20.0"
> >
> > #(use-modules (ice-9 syncase))
> >
> >
> >
> > #(define-syntax set-default
> >
> > (syntax-rules ()
> >
> > ((set-default name value)
> >
> > (if (eqv? name 'UNDEF) name value)
> >
> > )))
> >
> >
> >
> > #(define some-setting 44)
> >
> > #(set-value some-setting 99)
> >
> > #(ly:message "some-setting = ~a\n" some-setting)
> >
> >
> >
> > This gives the error:
> >
> > Wrong number of arguments to #<Music function
#<procedure #f
> > (arg)>>
> >
> >
> >
> > Huh? I also tried define-syntax-rule, which came up unbound. Any
insights
> > into what I'm doing wrong would be welcome.
>
> syntax-case doesn't work in LilyPond since LilyPond defines \void as a
> music function and the Guile 1.8 implementation of syntax-case falls
> apart if 'void has a value.
>
> You are not doing anything wrong other than expecting syntax-case to
> work. Stick to macros instead of define-syntax. Sorry for that.
>
> --
> David Kastrup