lilypond-devel
[Top][All Lists]
Advanced

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

Re: Issue 5310: find_top_context () maintenance (issue 341150043 by addr


From: dak
Subject: Re: Issue 5310: find_top_context () maintenance (issue 341150043 by address@hidden)
Date: Wed, 25 Apr 2018 03:44:22 -0700

On 2018/04/23 23:55:44, Dan Eble wrote:
David, would you accept a template class wrapping a non-null pointer,
perhaps
non_null_ptr<T>?  Conversion to a raw pointer would be implicit, but
construction from a raw pointer would be explicit.  The person
constructing such
a pointer is responsible for ensuring that it is not null.  The person
who uses
such a pointer trusts that it is not.

That would retain the pointers that you value and add the nullness
information
that I value.

Please note that all of your proposals so far do _not_ provide the
nullness information that you value in any manner: previously undefined
behavior would continue to be undefined behavior and would just look
differently.

Either way, to make this work at all in a mechanical manner, you need to
be consistent in the value creation chain.  That is, you cannot start
from unsmob (which may return null or not which is also used as a type
check) but would need to start with a different function delivering then
either a reference or the kind of null-checked pointer you now suggest.
Every further use must then retain this particular type, not allowing
for a piecemeal conversion of the code conventions.  The latter would at
least have the advantage of somewhat definable semantics (like implicit
conversion to pointer) making for a somewhat softer conversion and
giving somewhat more dependable semantics than just replacing pointers
by references.

It still has the disadvantage of adding a new class as baggage, making
it harder for newcomers interpreting code.  In particular the necessity
of overloading *, &, and -> operators raises the amount of knowledge
required for maintenance and debugging.  I am rather doubtful that this
would be a good tradeoff so I would not want to encourage you to indulge
in a significant amount of work here which I may not want to see added
to the code base after all.

https://codereview.appspot.com/341150043/



reply via email to

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