lua-users home
lua-l archive

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


Phoenix,

I just found out about LGMP
(http://members.chello.nl/~w.couwenberg/lgmp.htm), I think it is a
nice solution for representing 64-bit integers in Lua if you want to
hack something up quickly, as it has both arithmetic and bitwise ops
if you want to hack something up quickly. If you want to do it by
modifying Alien I suggest you check out the head at
http://github.com/mascarenhas/alien/tree/master, as I did some
refactoring of Alien's code that makes adding new types a little
easier.

The way I will do it for Alien when I get around to implemeting this,
though, is to use a 64-bit long userdata, and have bitops as methods
of this userdata's __index metamethod (plus conversion to and from
strings, and arithmetic/relational metamethods, of course).

--
Fabio Mascarenhas

On Thu, Jul 9, 2009 at 2:12 AM, Fabio Mascarenhas<mascarenhas@gmail.com> wrote:
> Phoenix,
>
> I just found out about LGMP
> (http://members.chello.nl/~w.couwenberg/lgmp.htm), I think it is a
> nice solution for representing 64-bit integers in Lua if you want to
> hack something up quickly, as it has both arithmetic and bitwise ops
> if you want to hack something up quickly. If you want to do it by
> modifying Alien I suggest you check out the head at
> http://github.com/mascarenhas/alien/tree/master, as I did some
> refactoring of Alien's code that makes adding new types a little
> easier.
>
> The way I will do it for Alien when I get around to implemeting this,
> though, is to use a 64-bit long userdata, and have bitops as methods
> of this userdata's __index metamethod (plus conversion to and from
> strings, and arithmetic/relational metamethods, of course).
>
> --
> Fabio Mascarenhas
>
>
>
> On Thu, Jul 9, 2009 at 12:54 AM, Phoenix Sol<phoenix@burninglabs.com> wrote:
>> Sigh; I was ignorantly hoping that these things could be 'implicitly
>> converted' on the C side.
>> ( Though not very optimistic about the result of doing so. )
>>
>> I really need to make the time to learn C; which shall I give up: sleeping,
>> eating, or my children?
>> ( I've already given up entertainment, social life, and sex. )
>>
>> Phoenix Sol
>>
>>
>> On Wed, Jul 8, 2009 at 10:29 PM, Sam Roberts <vieuxtech@gmail.com> wrote:
>>>
>>> On Wed, Jul 8, 2009 at 8:05 PM, Phoenix Sol<phoenix@burninglabs.com>
>>> wrote:
>>> > Thanks, Sam.
>>> >
>>> > I tried doing this:
>>> >   tyr.tcrdbrnum:types('double', 'pointer')  --( that's return type, arg
>>> > type(s), in case you don't speak Alien ) ( and Alien will try to convert
>>>
>>> I'd never heard of alien before this post. It doesn't surprise me the
>>> things you tried failed. You have to tell alien the truth about the C
>>> API, it won't be able to magically figure out what you want it to do.
>>>
>>> I'd talk to Fabio, I think he could modify Alien (or you could) pretty
>>> trivially so that it used decimal strings on the lua side for
>>> (u)int64s on the C side. Without that, you aren't going to be able to
>>> use Alien, I don't think.
>>>
>>> Sam
>>
>>
>