[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
**Subject**: **Re: Lua language extension for complex number and vector values**
**From**: David Manura <dm.lua@...>
**Date**: Wed, 30 Mar 2011 21:20:38 -0400

On Tue, Mar 29, 2011 at 7:36 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> tuple[3] A,B -> expands to local A_1,A_2,A_3,B_1,B_2,B_3
I too have been thinking about this type of solution [1].
[1] http://lua-users.org/wiki/SourcePreprocessing
On Tue, Mar 29, 2011 at 3:30 PM, Francesco Abbate
<francesco.bbt@gmail.com> wrote:
> I understood that what I proposed cannot work because in
> order to perform the right arithmetic operation the Lua VM inspect the
> TValue and there isn't any way it can figure out that the value is
> part of a vector or not.
I don't see why this is a problem. In the following case:
-- input
local a[2], b[2], c[2], d = ...
c = a + b * d + f()
you know at compile time which operations must be interpreted as
vector operations because the lexical variables are statically typed
as vector. The above would be translated into
-- output
local a1,a2, b1,b2, c1,c2, d = ...
local _tmp1 = f() -- assume scalar if not explicit
c1 = a1 + b1 * d + _tmp1
c2 = a2 + b2 * d + _tmp1