lilypond-devel
[Top][All Lists]
Advanced

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

Re: Provide some more smob functionality and use it (issue 135240043 by


From: dak
Subject: Re: Provide some more smob functionality and use it (issue 135240043 by address@hidden)
Date: Sun, 31 Aug 2014 17:03:10 +0000

On 2014/08/31 16:45:37, lemzwerg wrote:
LGTM.  Very nice!  This indeed feels more C++ now.

Well, it is sort of cheating C++.  In order to avoid polymorphism
(virtual functions, vtable, dynamic_cast etc) for the lightweight smobs,
this uses templates for a sort-of back-and-forward inheritance: the base
smob class knows its super class via a template parameter, and the super
class knows its
base smob class via inheritance.  Overrides work via the base class
accessing Super::whatever which falls through to the base class unless
defined in Super.  So the code ends up somewhat similar to the macro
code.  And the access of Super::whatever has about the type safety of
macro code as well.  Which is convenient since "please ignore this by
default" functions can be defined to be constant zero and the access
gets optimized away completely.

The end result is pretty much like "virtual overrides" with regard to
the coding style for the user but more memory- and code efficient.  And
the total light-weight smobs Smob1..Smob3 cheat by having no data
members and misusing "this" as an SCM value (SCM is defined as a pointer
by default as well).  With the result that source looks like with the
non-lightweight smobs but the generated code is close to non-existent.


https://codereview.appspot.com/135240043/diff/20001/scripts/auxiliar/smob-convert.sh
File scripts/auxiliar/smob-convert.sh (right):


https://codereview.appspot.com/135240043/diff/20001/scripts/auxiliar/smob-convert.sh#newcode2
scripts/auxiliar/smob-convert.sh:2: for i in $(git grep -l
'^\s\+DECLARE_SIMPLE_SMOBS' lily)
Will this script be ever used again?  It perhaps deserves a comment...

The script will not get used again except possibly by people having a
large amount of code in an unconverted branch.  The script will not make
it outside of the branch: its existence will get reverted away at the
end.  If people need it, they'll have to cherry-pick it out of the
branch.  There is no real point in retaining the script even though it's
sort-of educational.  But it does not apply to anything after having run
once.

https://codereview.appspot.com/135240043/



reply via email to

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