lua-users home
lua-l archive

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


On Friday 11 June 2004 22:57, Virgil Smith wrote:
> Lua forces copy semantics for simple value types (nil, boolean, number,
> string, light userdata) and reference semantics for complex types
> (function, table, userdata).
>
> I have a colleague using Lua in a project that has a strong need for
> passing parameters by reference (problem set is the multivariate
> optimization of a complex system).

Since Lua allows multiple return values, you can always just use the idiom:

a = f(a)

regardless of how many parameters you need to change. There is never an actual 
need for passing parameters by reference. It just might be notationally 
convenient in some cases, but arguably doing so would just make your code 
harder read.

-- Jamie Webb