lua-users home
lua-l archive

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

On Tue, Apr 15, 2008 at 9:40 AM, Matias Guijarro
<> wrote:
>  Consider a XML-RPC server in Lua : exported functions and
>  "objects" in the global environment are available for clients. If
>  a client makes a request like this : "", the server needs
>  to know how to execute the request.

IMO, if the syntax doesn't make any difference then you shouldn't try
to guess. make the client call with the explicit parameter:, ...)

>  Is there some debug library magic to be able to have a hint ?
>  I wonder, because for example if we know that the first
>  argument of function "bar" is "self", it probably indicates
>  that it should be called with ":" ... Well, even that is not a
>  good solution :-(

quite often, i find that several of my functions begin with a 'main'
parameter, so i just put refs to the functions in a metatable, and
turn the object into an 'object'.

ej, from Xavante:

there's a xavante.send_data(res, data), so in the 'res' metatable i
added {send_data=xavante.send_data}, so i could do res:send_data(data)

the very same function is used as a 'method' and as a 'regular function'.

the whole string package suffered the same transformation: in the docs
there's string.find(str, xxx), but all strings have 'string' as the
metatable, so you can do str:find(xxx).  nothing special in the
function itself.

OO is a style, not a feature.