lilypond-devel
[Top][All Lists]
Advanced

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

Re: Use more const Grobs in the Paper_column interface (issue 346100043


From: dak
Subject: Re: Use more const Grobs in the Paper_column interface (issue 346100043 by address@hidden)
Date: Tue, 19 Jun 2018 16:15:42 -0700


https://codereview.appspot.com/346100043/diff/1/lily/paper-column.cc
File lily/paper-column.cc (right):

https://codereview.appspot.com/346100043/diff/1/lily/paper-column.cc#newcode105
lily/paper-column.cc:105: SCM m = me->get_property ("when");
On 2018/06/19 22:41:09, Dan Eble wrote:
On 2018/06/19 06:08:56, dak wrote:
> How much sense does this make?  get_property on callbacks will
execute various
> sorts of callbacks the first time a property is accessed and store a
cached
> result.  So the grob is only "const" because accessing its
properties happens
> via a linked list where only the data structure organization rather
than the
> data itself happens to affect the formal Grob constness.  Which is
sort of an
> implementation detail.

If the effect of the callbacks is limited to lazy initialization, I am
comfortable with get_property() being a const method.

Here's wisdom:

https://isocpp.org/wiki/faq/const-correctness#logical-vs-physical-const

The callbacks are not really "lazy initialization" since they are
sometimes divided into pure/unpure, usually have considerable timing
constraints with regard to when they may be called, and quite a few have
significant side effects, like after-line-breaking.  All of them protect
against circular evaluation.  Due to the significant timing constraints
caching of values is not really conceptually const: in fact, a number of
properties are evaluated solely in order to trigger that side effect in
certain situations.

My question was exactly because compiler formally the contained linked
list heads are considered "const" while conceptually they aren't as the
rest of the list is being tampered with.

https://codereview.appspot.com/346100043/



reply via email to

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