Re: Strange error from define-syntax

2020-05-28 Thread David Kastrup
"John Schlomann"  writes:

> define-macro works perfectly for me, even though the Guile manual seems to
> somewhat disparage its use.

Well, it's not the modern Scheme way but at the current point of time
LilyPond works best with Guile 1.8.

-- 
David Kastrup



RE: Strange error from define-syntax

2020-05-28 Thread John Schlomann
define-macro works perfectly for me, even though the Guile manual seems to
somewhat disparage its use.

Thank you, David.

John

> -Original Message-
> From: David Kastrup [mailto:d...@gnu.org]
> Sent: Thursday, May 28, 2020 2:02 PM
> To: John Schlomann
> Cc: 'Lilypond-User Mailing List'
> Subject: Re: Strange error from define-syntax
> 
> "John Schlomann"  writes:
> 
> > 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?
> 
> define-macro and defmacro apparently.
> 
> --
> David Kastrup




Re: Strange error from define-syntax

2020-05-28 Thread David Kastrup
"John Schlomann"  writes:

> 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?

define-macro and defmacro apparently.

-- 
David Kastrup



Re: Strange error from define-syntax

2020-05-28 Thread Valentin Villenave
On 5/28/20, John Schlomann  wrote:
> 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?

I think David may have been referring to LilyPond macros; have a look
at that for example:
http://lilypond.org/doc/v2.21/Documentation/extending-big-page#interfaces-for-programmers

Cheers,
-- V.



RE: Strange error from define-syntax

2020-05-28 Thread John Schlomann
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:d...@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"  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 # > (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




Re: Strange error from define-syntax

2020-05-28 Thread David Kastrup
"John Schlomann"  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 # (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