[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Extending Lua-RPC: questions about handling index and call events
- From: James Snyder <jbsnyder@...>
- Date: Wed, 3 Jun 2009 19:25:57 -0500
On Jun 3, 2009, at 6:00 PM, Geoff Leyland wrote:
That's a tough one - how would you handle
remote_cos = handle.math.cos
res = remote_cos(3.1)
As it stands, since what you get back when you index is a helper, that
would execute the call on the remote machine.
table_I_want_transferred_in_its_entirety_now = handle.a_table
Can you work out a user's intentions without extra syntax?
Right. The user might want the table or they may just want to refer
to it by a different name for later reference.
You could obviously have some kind of evaluate function:
res = rpc.evaluate(handle.sometable.entry)
but I guess you're trying to avoid that because you didn't mention it?
I could, but I do rather like the simplicity of just working with it
from the handle :-)
Would lazy evaluation work? You could not do anything until the
object is used by a __call, __tostring, __add or some other
metamethod. There would be the usual problem with comparison
operators, but it would work some of the time I think.
That works for a fair number of things so long as there's a metamethod
that can be hooked prior to an operation.
It does get weird with something like:
value_from_server = handle.some_value
value_from_server + local_value
or even things like:
value_from_server + handle.some_other_value
To me it would make the most sense to, when possible, pull both to the
local environment, and then perform the local operation as it would
with that type. I wonder if that could be cleanly generalized
somehow? It would be nice to be able to do things like call
math.cos(handle.some_remote_value) without having to explicitly copy
it from the remote to the local state. For things like this,
It doesn't have to perfectly handle every situation. My main goals
are to make it easy to execute functions on a remote session, and to
make it pretty easy to get data from the remote environment for
further local processing.
Perhaps the easiest approach is to do lazy evaluation, where the
helper can handle __call (to call a remote function), __index (to
index deeper into multiple layers of tables), and a method like "get"
or "copy" that would take anything it knows how to serialize and copy
it to the local stack.
Thanks for your comments and thoughts :-)
Any other suggestions? (doing it all from a module without modifying
Lua itself would be best)
ph: (847) 448-0386
Description: This is a digitally signed message part