lua-users home
lua-l archive

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

Title: RE: suggestion : method to push constant strings

> It is likely that the size of a 'double' on your architecture is 64
> bits.  If it is, and the Lua script doesn't actually do any operations
> on the string (just passes it through to C), you can implement a fake
> 32-bit pointer by passing the pointer as a double through
> lua_pushnumber().

I have put this idea on the back burner. I'm still using the old
API (Lua 4.0 alpha), and I have a handful of issues to address
before going to the new API (mostly changing the various userdata
I use (quite a lot) to use numbers (I've modified Lua to use 32
bit signed ints instead of doubles). I'm waiting for the final
version and Lua changes to be settled before actually deciding
what to do, but your suggestion seems attractive, though Lua's
internal typing gets bypassed completely. It's very useful to
be able to describe a given location in a map either by a set
of coordinates (computed from existing coordinates and deltas,
for instance), which are numbers, or a string representing a
waypoint stored in a game, or a table representing the location
where a given game object is currently located. Doing this kind
of things would be harder if everything would be passed through
a simple number (eg I would have to do my own typing, probably
by extending Lua's type structure). Not something I see with lots
and lots of good feelings :)

Vincent Penquerc'h