[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Macro pre-processing?
From: |
Mats Bengtsson |
Subject: |
Re: Macro pre-processing? |
Date: |
Sat, 29 Apr 2006 21:04:51 +0200 |
User-agent: |
Internet Messaging Program (IMP) H3 (4.0.4) |
Quoting Geoff Horton <address@hidden>:
\define-music-function {\foo \x \y} { c8 \x d8 \y }
...
{ \foo e16 {f g} }
=>
{ c8 e16 d8 {f16 g16} }
The usefulness of this kind of function is disputed among developers, so it
might not become part of the official lilypond distribution.
I am not a developer (though I do read the dev list), but I would
certainly use such a thing if it existed, and it would do most of the
things (and maybe all of them) for which I wanted a pre-processor.
Using the techniques currently available in LilyPond, Erik's example
is easily implemented as:
foo = #(define-music-function (parser location x y) (ly:music? ly:music?)
#{
c8 $x d8 $y #})
{ \foo e16 { f g }}
As you see, you don't really need any Scheme competence to do it. Lines
1, 2 and 4 of the macro definition will look almost the same for any
such macro definition. The only thing you have to change in the first
line is the name of the variables (here called
x and y) and what type they have. Here, both input variables are
music expressions, which is specified with the "ly:music?". The example
at the end of "11.1.6 Using LilyPond syntax inside Scheme"
shows how to make a macro where the second argument instead is a
numeric value.
I actually think that the current support is fairly easy to use. If the
manual just included a few more examples with different number and type
of arguments, then any person being able of doing
simple pattern matching would be able to use it without any major
troubles. I'll try to come up with a proposal for the manual.
/Mats
- Re: Macro pre-processing?, (continued)
- Re: Macro pre-processing?, Geoff Horton, 2006/04/06
- Re: Macro pre-processing?, Werner LEMBERG, 2006/04/06
- Re: Macro pre-processing?, Erik Sandberg, 2006/04/26
- Re: Macro pre-processing?, Geoff Horton, 2006/04/26
- Re: Macro pre-processing?,
Mats Bengtsson <=
- Re: Macro pre-processing?, Geoff Horton, 2006/04/29
- Re: Macro pre-processing?, David Feuer, 2006/04/29
- Re: Macro pre-processing?, Nicolas Sceaux, 2006/04/30
- Re: Macro pre-processing?, Geoff Horton, 2006/04/30
- Re: Macro pre-processing?, Mats Bengtsson, 2006/04/30
- Re: Macro pre-processing?, Graham Percival, 2006/04/30
- Re: Macro pre-processing?, Geoff Horton, 2006/04/30