[Top][All Lists]

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

Is gcc able to handle anonymous functions?

From: Marc Hohl
Subject: Is gcc able to handle anonymous functions?
Date: Wed, 04 Jul 2012 09:35:34 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

Hello list,

the topic is somewhat over my head, but perhaps someone with more insight
can answer this question?

Alternatively, I have a scheme function returning a boolean. This function has to be called from inside some c++-routines, but this doesn't work yet (see below).



-------- Original-Nachricht --------
Betreff: Re: Questions about Issue 1320: Scheme bar line interface (issue 6305115)
Datum:  Wed, 4 Jul 2012 06:48:56 +0200
Von:    address@hidden <address@hidden>
An:     Marc Hohl <address@hidden>

Hey Mark,

This is because, in this instance, you need to pass the function a pointer to a function and not a bool. You can accomplish this through anonymous functions in C++11. What'd be ideal is to create a C++ macro that takes a scheme function plus a number of arguments and returns a C++ pointer to an anonymous function.

I'll have a look in the train today and write you a more detailed response. In the meantime, ask the devel list if the gcc compiler can handle the types of anonymous functions specified here:

All the best,

On 3 juil. 2012, at 22:17, Marc Hohl wrote:

Hi Mike,

thanks for your quick answer!

Am 03.07.2012 21:13, schrieb address@hidden <mailto:address@hidden>:

Hey Marc,

If the function is reused three times, you can rewrite it in Scheme. Sorry for not having picked up on that. You can do a module call-up as you had suggested before.

I don't get it right, compilation fails In static member function 'static Spring Note_spacing::get_spacing(Grob*, Item*, Real, Real)': error: no matching function for call to 'Pointer_group_interface::find_grob(Item*&, SCM, bool&)' note: candidate is:
./include/pointer-group-interface.hh:36:16: note: static Grob* Pointer_group_interface::find_grob(Grob*, SCM, bool (*)(Grob*)) ./include/pointer-group-interface.hh:36:16: note: no known conversion for argument 3 from 'bool' to 'bool (*)(Grob*)'
make[1]: *** [out/note-spacing.o] Error 1

This is how I tried to include the bar-line::non-empty-barline function, defined as

(define-public (bar-line::non-empty-barline grob)
 (and (grob::has-interface grob 'bar-line)
      (pair? (ly:grob-extent grob grob X))))

diff --git a/lily/ b/lily/
index 4772367..074ad8d 100644
--- a/lily/
+++ b/lily/
@@ -20,7 +20,6 @@
#include "note-spacing.hh"

#include "accidental-placement.hh"
-#include "bar-line.hh"
#include "directional-element-interface.hh"
#include "grob-array.hh"
#include "moment.hh"
@@ -90,9 +89,11 @@ Note_spacing::get_spacing (Grob *me, Item *right_col,
      && !skys[RIGHT].is_empty ()
      && to_boolean (me->get_property ("space-to-barline")))
+      bool non_empty_barline =
+ ly_scm2bool (scm_call_1 (ly_lily_module_constant ("bar-line::non-empty-barline"), right_col->self_scm ()));
      Grob *bar = Pointer_group_interface::find_grob (right_col,
ly_symbol2scm ("elements"),
- Bar_line::non_empty_barline);
+ non_empty_barline);

      if (bar)

reply via email to

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