lilypond-devel
[Top][All Lists]
Advanced

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

Re: Naming question for get_property, set_property


From: David Kastrup
Subject: Re: Naming question for get_property, set_property
Date: Tue, 11 Feb 2020 14:40:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Dan Eble <address@hidden> writes:

> On Feb 10, 2020, at 20:48, David Kastrup <address@hidden> wrote:
>> 
>> Templating on a string constant is, unfortunately, not a thing at least
>> in C++11 (don't know whether they managed since then).  Or one could go
>> that route rather than GCC-specific in-expression use of a static
>> initializer.
>
> Well, constexpr enables some new and interesting things, though I
> imagine that having to interact with Guile nixes them.

For the purpose of generating a near-compile-time constant that would
not be a problem, static initialization to the win.

Like

template <const char *symbol>
SCM make_symbol ()
{
  static SCM sym = scm_permanent_object (scm_string_to_symbol (symbol));
  return sym;
}

which would generate one function per symbol that on its _first_ call
(when the Guile subsystem is already active) converts the symbol into
SCM and then memoizes it.  But as far as I know, C++11 cannot template
on string constants (C or C++) like that.  You need to create a named
character array or pointer and then can template on _that_ and that's a
lot more cumbersome in practice.

> Here, someone has figured out how to compute a CRC of a literal string
> at compile time: https://stackoverflow.com/a/9842857

We would not need anything that complicated.

-- 
David Kastrup
My replies have a tendency to cause friction.  To help mitigating
damage, feel free to forward problematic posts to me adding a subject
like "timeout 1d" (for a suggested timeout of 1 day) or "offensive".



reply via email to

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