[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modifying lua for table indexing with fixed point variables
- From: "Gregory Lamoureux" <greg.m.lamoureux@...>
- Date: Mon, 28 Apr 2008 15:50:10 -0400
Thanks everyone, I was able to solve the problem. Instead of modifying lparser.c, I modified the addk() function within lcode.c to convert table indexes from fixed point to integer for when ttisnumber(v) is true. This function was always called for dereferencing table indexes after the argument _expression_ was resolved. (t[a+b-1], t[2], etc...)
On 28/04/2008, Gavin Wraith <gavin@wra1th.plus.com> wrote:
In message <4815F4D6.1050100@hempeldesigngroup.com">4815F4D6.1050100@hempeldesigngroup.com> you wrote:
> I've been down this road too, using standard 32bit long as the
> fundamental number type and then trying to wedge single precision
> floats in as a special case.
>
> After about a year of messing around, I came to the conclusion that
> the times that I need floats are generally well known, and the user
> has to think about when to use them as well, so why not just make
> them a special userdata type with a metatable to deal with the
> common arithmetic operators.
I had a similar experience with RiscLua ( http://lua.riscos.org.uk/ ),
a port to a platform based on ARM architecture chips with only
software support for floating point. I tried various shifts to have
my cake (32-bit integers for standard integers) and eat it (also
have some fp facilities). I tried the mapm library and decided nobody
would use it. In the end I did the same as you, and implemented
arithmetic with doubles via userdata. I also extended the Lua VM with
bitwise operations. See history at
http://www.wra1th.plus.com/lua/version.html .
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/