lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Constructive Criticism and a Question


From: Erik Sandberg
Subject: Re: Constructive Criticism and a Question
Date: Sun, 7 Jan 2007 12:42:45 +0100
User-agent: KMail/1.9.5

On Sunday 07 January 2007 04:55, address@hidden wrote:
> > > > . . . Note also that the tupletSequence
> > > > function  would be implemented entirely in Scheme . . .
>
> I'm not very fluent in Scheme, so this is a naive question.
>
> I presume that ratios like 3:2 (or 2/3) could be made into some kind of
> object type (possibly a "moment").  So I could imagine that it would be
> possible to write a Scheme function definition to cover a syntax like
>
>    \tupletSequence m:n #'( {...} {...} ... )
>
> where the first argument is a moment and the second is a list of literal
> music expressions.  (And I suppose I'm too optimistic about that syntax;
> probably those {...} would have to be sprinkled with # or $ or other
> spices.)  But there are some questions:
>
> 1) I don't see how this could accommodate the case where one of the music
> expressions *were* a variable reference (\var) or *contained* a variable
> reference.

Music functions are not macros; the arguments are evaluated before the 
function is called. So \var always means to dereference a variable.

(I'm working on a system for 'music macros', which should make it possible to 
delay the dereferencing of variables, this will mainly be useful to clean up 
\relative)

> 2) Because the syntax      \tupletSequence m:n { {...} {...} }
> is "nicer", it would be good if it could be written that way, but then the
> second argument would not be a standard Scheme entity, so I don't see how
> Scheme could handle it at all.

There is a distinction between Scheme functions and Music functions. Music 
functions are invoked as \function arg1 arg2, while Scheme functions are 
invoked in Scheme expressions, as #(function arg1 arg2). tupletSequence would 
be a music function.

There are three types of arguments to music functions: Music, Markup and 
Scheme. This suggestion would add another argument type 'fraction'. The 
parser takes care of identifying argument types. Music arguments are notated 
as music, so you can use {{c}{d}} syntax out-of-the-box. E.g., partcombine is 
a music function.

In Scheme functions, you can use the #{ #} syntax to easily create music 
expressions as arguments.

> Can tupletSequence really be defined in pure Scheme, as long as the parser
> is modified to recognize the object m:n or n/m (so that there would exist
> a type-verification-name for the object m:n for use in defining Scheme
> functions)?

yes, the only thing we need is a new parameter type.

BTW, one of the biggest problems (IMHO) in the lilypond language is that we 
can't extend the parser to accept durations as parameters to music functions: 
\foo c 4. is ambiguous; it's unclear whether the 4. is the c's duration, or 
if it's a separate argument.

-- 
Erik




reply via email to

[Prev in Thread] Current Thread [Next in Thread]