lua-users home
lua-l archive

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


I think I mentioned this once before but Lua 5.2 may be a decent basis to implement the Obliq distributed object model. See http://lucacardelli.name/Obliq.html for papers; here's the Lua-flavored summary:

The cute trick is that during an RPC call, code and values move over the network but references (such as upvals and tables) are replaced with network references pointing back to their defining scope. You are welcome to call

  compute_server(function() os.exit() end)

as "os“ remains lexically bound to the os on the *calling* machine. Which means you just took the long way to call your local os.exit().

But what if you want to use functionality on the compute-server end? Real compute servers will pass in the services they are willing to provide in a sanitized version of their local environment:

    c_s(function(services) services.os.exit() end)

The implementation problems are a robust RPC which marshals network references, and then of course distributed GC. The usage problems are the security nightmare of making sure stray references to sensitive objects do not escape, and that RPC does not really scale beyond a LAN--especially when you can accidentally be ping-ponging calls because you forgot to pick up the compute server's version of ipairs().[1]

Still, within certain problem domains it might be useful, and a fun student project. The real art would be figuring out how to restrict the environment such that the above problems never bite you.

One obvious thing is to make it easy to deep-copy tables as part of function call itself. An optimizer for

  remote_f(deepcopy(t))

could notice there cannot be any stray references to the table deepcopy(t) lying around and is therefore safe to send as a value rather than a reference--no need to actually do the deepcopy in fact. Any mutations to deepcopy(t) can't be noticed either.

Jay