lilypond-devel
[Top][All Lists]
Advanced

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

Re: Implement partial function calls. (issue 249670043 by address@hidden


From: dak
Subject: Re: Implement partial function calls. (issue 249670043 by address@hidden)
Date: Fri, 10 Jul 2015 11:00:26 +0000

Reviewers: Trevor Daniels, mark_opus11.net,

Message:
On 2015/07/10 10:34:24, Trevor Daniels wrote:
If I understand this correctly it permits a variable definition to be
used in
some circumstances where a music function definition would previously
have been
required to achieve the same effect.

Well, tiny correction: it just _looks_ like a variable definition.  What
falls out is a music function definition (or event function or scheme
function, depending on what the last function call happens to be).

It's mostly syntactic sugar (arguments present in the definition are not
evaluated and typechecked again, so it's a bit better than open-coded
when looking at stuff like a long tweak cascade).

That seems a worthwhile improvement and simplification.

The main problem I see is that if your only tool is a hammer, you start
viewing your problems in terms of nails.  This works for a cascade of
tweaks, but, say, not for overrides.  So you make it work with an
override only to realize overrides don't cascade but are placed in
sequence.  Oops.  So you want
xxx = { ... \incomplete } as well.  And so on.

So what I fear is that it's opening a can of worms because people would
like to be able to do more in that manner.  And it might be hard to
stuff the genie back into its bottle again...

Description:
Implement partial function calls.

Contains two commits, see particularly the regtest as an example.

I'm not convinced this idea is as good as I thought when coming up
with it: it may be that this particular use case is not frequent
enough to warrant the complexity.

It seems nice for defining aliases like

tagv = \tag '(violinI violinII) \incomplete

or

important = \tweak color #red \tweak font-size 3 \incomplete

but I'm not sure that this warrants the effort.

Discuss.


Allow for chaining of several partial functions in a row

Chaining only works when all function calls except the last one have all
arguments supplied already, with their last argument being the rest of
the chained call.

Implement partial function calls

A partial function call acts as a function where the start of the
argument list has already been supplied.  For example:

makeRed = \tweak color #red \incomplete

Then one can use this as

{ c' \makeRed d' e'-\makeRed -. }

Please review this at https://codereview.appspot.com/249670043/

Affected files (+161, -0 lines):
  A input/regression/music-function-incomplete.ly
  M lily/include/lily-imports.hh
  M lily/lily-imports.cc
  M lily/lily-lexer.cc
  M lily/parser.yy
  M scm/ly-syntax-constructors.scm





reply via email to

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