lilypond-devel
[Top][All Lists]
Advanced

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

[Parser] Lookahead in music function arguments


From: David Kastrup
Subject: [Parser] Lookahead in music function arguments
Date: Sun, 07 Oct 2012 20:11:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Hi,

I am trying to get into somewhat consistent music function behavior.
Some argument types for music functions inherently require lookahead:
simple music expressions like c4 (since you can still add -\accent at
will), symbol chains (like Bottom as it may be followed by
. Accidental), durations like 4. since further dots may follow.

If something like

\language "italiano"
sol

is supposed to work, strings may not require lookahead, or sol will not
be recognized in Italian mode.

In general, not requiring lookahead makes things more versatile.

Now there are things like 3\cm which I currently allow as function
arguments.  But that means that an unadorned 3 is not complete without
checking the lookahead for a number identifier.  I don't think there is
any function yet that actually uses numerical arguments like that, and
one can always get by with writing #(* 3 cm) or ##{ 3\cm #}.

Even if we have functions taking numeric arguments, it would likely be
surprising that something like

add = #(define-scheme-function (parser location a b) (number? number?)
     (+ a b))
y = 7
z = \add 4 \y

will complain since 4\y evaluates to 28 and no second numeric argument
follows.  Huh.

I lean towards letting numbers in function arguments just evaluate to
themselves, never mind units.  In particular integers are used quite
often in manners where a "unit" behavior of identifiers would be rather
more than less surprising.

-- 
David Kastrup




reply via email to

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