Le 02/09/2022 à 13:17, Dan Eble a écrit :
On Sep 2, 2022, at 04:42, Jean Abou Samra <j...@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