lilypond-user
[Top][All Lists]
Advanced

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

Re: Appreciation / Financial support


From: David Kastrup
Subject: Re: Appreciation / Financial support
Date: Tue, 29 May 2012 08:01:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Han-Wen Nienhuys <address@hidden> writes:

> On Mon, May 28, 2012 at 3:17 PM, David Kastrup <address@hidden> wrote:
>> It would be nice to have fewer incompatible modes, and simpler ways of
>> extending them.
>>
>> And "the C++ must go" with regard to how LilyPond can be extended.  If
>> parts of LilyPond require "object orientation", then the respective
>> tools need to be available from Scheme.  No user can be expected to
>> recompile.
>
> Just a word of caution: scheme is a dynamic language, so programming
> errors will only discovered at runtime, which requires a lot of
> investment in testing.

> I think that the current setup where large parts are in C++ is pretty
> good, since it gets us both type checking and runtime speed.

Well, I prefer reasonably pinpointable runtime errors over crashes.
Mike is a big fan of C++ and admits to not understanding garbage
collection.  And we had several hard to track down errors with strange
symptoms because of that combination already.  When programming In
Scheme, you don't need to know about garbage collection.

> (the thought of having to go in and change -let's say- the
> partcombiner without breaking anything makes me shudder.)

Just recently I fixed a bad loop condition causing unprotected memory in
the part combiner...  Had been there for eternities.

We have things like

    void
    Time_signature_engraver::process_music ()
    {
      /*
        not rigorously safe, since the value might get GC'd and
        reallocated in the same spot */
      SCM fr = get_property ("timeSignatureFraction");
      if (!time_signature_
          && last_time_fraction_ != fr
          && scm_is_pair (fr))
        {

Scary comment, right?  Also wrong because of

    void
    Time_signature_engraver::derived_mark () const
    {
      scm_gc_mark (last_time_fraction_);
    }

Both sections written by you, though admittedly the latter section in
2005, and the former in 2000 when it may have been accurate still.

Bad input tends to let LilyPond segfault.  You need C++ for that: it is
not possible in Scheme alone.  Take a look at listener.cc, one of our
simplest C++ classes with things like

SCM
Listener::mark_smob (SCM sm)
{
  Listener *me = (Listener *) SCM_CELL_WORD_1 (sm);
  if (me->type_)
    (me->type_->mark_callback) (me->target_);
  return SCM_EOL;
}

and macros like IMPLEMENT_TRANSLATOR_LISTENER, IMPLEMENT_LISTENER,
GET_LISTENER.  If you want to figure out what it does as an average
programmer, you'll spend a day.

It creates a simple closure.  A trivial one-liner in Scheme.  No need to
create a "type" tag and/or mark stuff.

-- 
David Kastrup



reply via email to

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