[texworks] A request about lpeg

Stefan Löffler st.loeffler at gmail.com
Mon Dec 29 13:14:41 CET 2014


Hi,

On 27.12.2014 01:47, Reinhard Kotucha wrote:
>  > > On linux there is no problem because texworks-lua scripts use the
>  > > lua installed by the user.
>
> Does it mean that /usr/bin/lua is invoked by TeXworks in order to
> process external lua scripts or does it mean that the Lua sources
> present on a Linux system are compiled into the TeXworks binary?

So far, this thread dealt (exclusively) with Windows. On Linux, the
situation is different.
On Linux, Tw uses the system's lua (through liblua*.so). On Windows, we
don't rely on an existing Lua installation (in a standard location), so
lua52.dll is distributed alongside Tw.

> I hope that the latter is true, otherwise it's impossible to make
> internal data structures of TeXworks available to Lua.

I don't know exactly what you mean. Inside Tw, we can (and do) export Tw
data structures and functions - otherwise Lua scripting would not be
possible. This only works inside Tw, however. So if you run a standalone
Lua interpreter, no Tw functionality is available (i.e., Tw does not
provide a standalone lua module; but then again, that would not make
much sense when Tw is not running).

> Assumed that Lua is compiled into TeXworks, what I don't understand is
> why different platforms are treated differently.  IMO platform
> independency is a must.

On the code level, they are not treated differently at all. You can
compile Tw with shared libraries or with static libraries, depending on
what you prefer.
Regarding the builds I provide: as stated (briefly) above, on Linux I
rely on the system libraries. On Windows, there is no easy way to ensure
all the libraries are installed in a system-wide manner, so there the
build uses static libraries (also to avoid interferences with different
library versions, etc.). But again, this is just a matter of
compile-time switches, and nothing inherently platform-dependent. If you
want, you can build on Windows with shared libraries as well (in fact,
that's also the way that is documented
https://code.google.com/p/texworks/wiki/BuildingOnWindowsMinGW, but it
would be much harder in the cross-compiling environment I use, plus it
would overwhelm the user with dozens of dlls.

> I'm not convinced that it's a good idea to use the original Lua
> sources and libraries at all.  A better choice is texlua, a LuaTeX
> without TeX.  It's already present in all TeX distributions.  You'll
> find the sources in the TeX Live SVN repository.

OK. But can this be used in a platform (and TeX distro) agnostic way?
I.e., could I compile Tw once and then use it with TeXLive, MiKTeX,
etc.? In particular, please keep in mind that Tw not only calls the lua
interpreter, but in fact needs access to the C++ interface.


> You said
>
>  > I don't want to compile in (too many) modules because it somewhat
>  > contradicts the idea of modules
>
> What is the idea of modules?  All binaries in TeX Live are statically
> linked.  They are highly portable.  Even the ancient teTeX binaries
> from the mid-nineties still run on modern machines.  TeXworks isn't
> portable at all because it depends on particular versions of Qt which
> are not necessarily present on all systems.  Making things modular
> (using .so and .dll files) is certainly a bad idea.  IMO the only
> reasonable approach is to statically link texlua into TeXworks.

(At least for me), the idea of modular programming is that you separate
different parts of a program as much as possible and define a clear and
simple interface between them. That way, the separate modules become
easier to maintain and, possibly, can even be plugged in and out
depending on the users' needs.
In the case of Tw, we are not talking about the core code here. We are
talking about the scripting functionality. While I believe that it is a
very powerful and useful tool (and I guess several people on this list
will agree), it is a rather advanced tool. So I expect that many people
will never even touch it. Therefore, the idea was to design scripting
via a plugin framework: you download and install those plugins you use,
but not necessarily dozens of others you don't need and will never use.
As said above, however, the choice of building with shared or static
libraries is up to the person providing the binaries.
In my case, the reasoning is the following: on Ubuntu, things are
provided in central repositories. These repositories are specific for
each version of Ubuntu, each including a specific version of the
libraries. Therefore, there are Tw builds for different versions of
Ubuntu, all of which depend on the library versions in the respective
standard repository for the Ubuntu version in question. As long as you
work with that standard repository for your particular version of
Ubuntu, the Tw builds will work out of the box.
On Windows, no such central repository exists, so there I currently
build Tw statically. One exception recently added is lua, where
lua52.dll is used (and provided alongside Tw). This step was necessary
to avoid having to statically link against all possible lua modules
(many of which will never be used by most users), but instead allow
users to swap specific modules in and out as required.

Hope this clears things up a bit.
Stefan


More information about the texworks mailing list