lilypond-devel
[Top][All Lists]
Advanced

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

Re: A more automated LY_DEFINE?


From: Jean Abou Samra
Subject: Re: A more automated LY_DEFINE?
Date: Fri, 2 Sep 2022 13:20:21 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0



Le 02/09/2022 à 13:17, Dan Eble a écrit :
On Sep 2, 2022, at 04:42, Jean Abou Samra <jean@abou-samra.fr> wrote:
Does C++ provide tools for making this simpler? I'm thinking that something like

LY_DEFINE (ly_grob_relative_coordinate, ..., (Grob *g, Grob *refp, Axis a), ...)
{
   ...
   return ret;
}

would be equivalent to

LY_DEFINE (ly_grob_relative_coordinate, ..., (SCM g_scm, SCM refp_scm, SCM 
axis_scm), ...)
{
   auto *const g = LY_ASSERT_SMOB (Grob, g_scm, 1);
   auto *const refp = LY_ASSERT_SMOB (Grob, refp_scm, 2);
   LY_ASSERT_TYPE (is_scm<Axis>, axis_scm, 3);
   Axis a = from_scm<Axis> (axis_scm);
   ...
   return to_scm (ret);
}
This has been on my wish list for a while, which is why it is currently 
possible to pass overloaded functions to macros such as LY_DEFINE, and 
hand-code the function as a SCM function wrapping another function.  I suspect 
that David had similar thoughts when he created from_scm() and to_scm().

I might be willing to spend time on it in the future, although not very soon.

If it is not feasible, being told it before I try could save me time. I'm
not yet very familiar with C++ templating techniques.
It's hard to give any assurance about complicated problems one doesn't do every 
day.  I can confidently predict that the experience will involve an instance of 
trying something obvious that doesn't work and learning that it requires a more 
recent version of C++.

I don't want to discourage you, but this is a good thing to attempt when you're 
prepared for a steep learning curve and possible failure.



OK, thank you, I have been warned. I'll only attempt it if one day I
feel particularly bold.

Cheers,
Jean




reply via email to

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