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 22:17:34 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Han-Wen Nienhuys <address@hidden> writes:

> On Mon, Feb 10, 2020 at 11:48 PM David Kastrup <address@hidden> wrote:
>
>>
>> So for longterm efficiency reasons I am planning to reimplement the
>> get_property/set_property macros and underlying data structures that map
>> to get_property_internal/set_property_internal.  They are currently used
>> across a number of types in a sort of polymorphism, and for "reasons" I
>> need to know the type, so the call would become something akin to
>>
>> I'm curious about your plans. Can you say more?
>
>
>> get_property (Grob, "color");
>> or
>> set_property (Grob, "stencil", SCM_BOOL_F);
>>
>> Now this is longer than before.  Removing _property is not really an
>> option since that lands us with std::set getting mapped to
>> std::set_property_internal (or whatever).
>>
>> So Set and Get ?  Or set_prop and get_prop ?  Or Set_prop and Get_prop ?
>>
>> Or, since there are not all that many types to cater for, grob_set,
>> grob_get, music_set, music_get, event_set, event_get (those obviously
>> without the extra type argument) and what else I've been missing?
>>
>
> I recommend simply reverting to what we had before I unified things, ie.
>
>   get_grob_property
>   set_grob_property
>   get_music_property
>   .. etc.
>
> the reason being that it is better if the source code looks like plain C++,
> even though they might actually be macros that do advanced magic. Having
> normal looking source code helps editors and tooling (astyle, clang-format)
> make sensible decisions.

get_property (pointer, "property")
set_property (pointer, "property", value);

would achieve that as well.  Doesn't look like a member function, but
the thing looking like a member function also never actually was one.

Your proposal certainly causes fewer headaches in the sed script
department.  It's just that many uses of get_property/set_property
already lead to comparatively long lines.

And Dan appeared to be no fan of what will end up in code like

get_grob_property (grob, "property")

since usually the name of the pointer already suggests the type.  So I
lean toward's the non-member-function-like variant.  Let's see whether
my sed-foo convinces me otherwise when I get there.

-- 
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]