lua-users home
lua-l archive

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


On 01/15/2013 10:14 AM, Alexey Baskakov wrote:

First off, let me say I'm excited to see CSP coming to Lua. I've only
really played around with Go's implementation of CSP (which doesn't
strictly follow the original CSP IIRC.) It will be nice to play around
when I finally get this compiling[1].
Yeah, there is Microsoft Visual Studio 2010 solution only (for now).
Sorry about that. Portability and cross-platform support are on the way :)
Like I said, you can check out my fork on github (I'm not going to bother to submit a pull request unless you really want me to.) I've already got it compiling (manually with g++.) One thing which might be useful is using CMake since it can generate MVS solutions as well as Makefiles (or Ninja builds, which is becoming my preferred builder now.) Otherwise a plain Makefile is really good enough.

Now without having actually compiled and tested it, it sounds like it's
using a modified version of Lua 5.2's source code which will produce a
separate interpreter & library. Assuming that's true, how invasive were
the changes and how feasible would it be to make it a Lua module
instead? It could, for instance, build as a module on systems that
support/want it and build as a library (as a replacement to the standard
Lua) for those wanting to easily embed it (perhaps there's a better way,
but it's still morning here, so I'm not going to dwell on it too much.)

[1] GCC isn't currently supported, but I've fixed some of the cross
platform issues already on my github fork.
Not sure if LuaCSP is useful on it's own. It's more a framework now. You still have to write your "Fundamental Operations"
to get some sense. I have to develop a few high-level samples, maybe.
I guess the way I'd /like/ to use it would be two fold (depending on what I'm writing.) One would be the embedded route which is currently supported. The other would be more in pure Lua (or using C modules) being run from the standard Lua interpreter. Some things I'd like to be able to do:
* Use channels and composition to make some code concurrent.
* Write fundamental operations in plain Lua.

What I guess I'd like to be able to write is something like: http://pastebin.com/DQPZPPr9

I tried to escape invasive Lua changes as much as possible (as mentioned in Implementation Disclaimer section of the doc).

The only change in Lua 5.2.1 provided in LuaCSP repo is the usage of float for LUA_NUMBER.
Moreover, this is a separate complaint: simple substitution double -> float for LUA_NUMBER spawns many
errors and warnings in MSVC 2010. This wasn't that bad for Lua 5.1. I was forced to fix all the issues myself.
So, it should work with standard Lua except some warnings in regard to float<->double conversions.
Yeah, I figured that out after I decided to untar lua-5.2.1 on top of the LuaCSP repo and look at the git diff.
There is a requirement for LuaCSP: Lua has to be compiled with:
#define LUAI_EXTRASPACE sizeof(void*)
That's good to know. I didn't realize that just from my (quick) look at it.
The reason for this is to provide extremely fast mapping from lua thread to my custom C++ object.

I used to replace thread's global environment in Lua 5.1 but it's not that fast and doesn't work in Lua 5.2 anymore AFAIK.
Any suggestions?

Basically, it's quite easy to fix once I find efficient way of mapping thread->void* on unmodified lua. I'm going to provide that feature under
extra #define in LuaCSP config.

Alexey.