[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing Parameters by Reference
- From: Jamie Webb <j@...>
- Date: Sat, 12 Jun 2004 02:29:31 +0100
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