[haiku-development] Re: The Call for Scripting Languages: Lua

  • From: Donn Cave <donn@xxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 26 Sep 2009 08:35:47 -0700 (PDT)

Quoth Stephan Assmus <superstippi@xxxxxx>,

> I would only use the second approach, if you can be sure that the patch is 
> rock-solid. If it is, then why isn't it part of the official lua source 
> code, yet? I would be suspicious, even though I realize I might hurt the 
> feelings of whoever produced the patch. :-)

A good point.  Python had a patch like that years ago, from a very well
regarded developer but never accepted, so of course many versions later
it's now impossible to apply it to a modern Python release.

> Then there is the issue of re-entrant versus multi-threaded. re-entrant 
> basically means that you don't have some static/global variables getting in 
> the way. It does not automatically mean that the program would work as a 
> whole with regards to the interpreter state.
>
> So the first approach does sound more robust to me.

It's more or less how the Python binding works.  To introduce another
distinction, Python supports multiple threads, but the threads will
not execute Python instructions concurrently - they're serialized by a
mutex, and the BLooper has to acquire that mutex before returning
to the interpreter.  That works fine, and in fact since with Python
I never had the troubles other people report with Be API multithreading,
I have wondered if this system is accidentally more robust.

The thread support helps, though.  For example, all external functions
release the interpreter lock, so another thread can execute in the
interpreter while an I/O completes.  Imagine the whole application
stalling while some thread calls recv() - that would be awkward.

        Donn Cave, donn@xxxxxxxxxxx


Other related posts: