lua-users home
lua-l archive

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


On Jun 3, 2009, at 6:00 PM, Geoff Leyland wrote:

Hi,

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.


or

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)

--
James Snyder
Biomedical Engineering
Northwestern University
jbsnyder@fanplastic.org
http://fanplastic.org/key.txt
ph: (847) 448-0386

Attachment: PGP.sig
Description: This is a digitally signed message part