lua-users home
lua-l archive

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


On 12/21/2010 9:07 PM, Tim Mensch wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/21/2010 6:22 AM, Christian Tellefsen wrote:
Disadvantages:
- More verbose code.
- Harder to learn for C++ coders who don't know the Lua stack, and are
more used to working with classes and templates.
Both of these are drawbacks for me that would kill that as a complete
solution. I want my API to be accessible and easy to use, and while my
own experience includes writing assembly language and so thinking in
terms of a stack is second nature, I don't want to assume everyone who
uses my library will have those skills.

It's also easy to make a mistake that causes an obscure crash; there's a
reason I don't program in assembly language any more, after all. :)

I'm sure some other wrappers also have some of the advantages above, I
haven't looked at everything in depth, and it was some time ago. I'm
pretty happy with how it turned out, though.
Glad that worked for you. After this project I'll probably head down a
similar path to start with, and then figure out how to wrap it up and
make it pretty. :)

Tim
We might add a more end-user-friendly layer in the future, as well. But hey, first I make it work, then I make it pretty, then I make it fast, in that order.

The main issue with the wrapping is that it seems to me to be hard to support dynamic typing very well. For example, we may have an argument that's a position. For the position, the scripter can send in not only a vector, but also the name of a point, the unique ID of a game object, or a reference to a game object. All of these will resolve to a position.

But, in other cases the input might be a velocity vector, for which this wouldn't make sense.

So, the wrapper layer would have to be able to generate different binding code for these functions:

GameObject::SetVel(Vec3 vel);
GameObject::SetPos(Vec3 pos);

There might very well be a good solution, but I'm not (yet) sure what it is, or whether it actually will be that much better than:

// SetVel()

GameObject * self = luaX_checkgameobject(L, 1); // Note: Will call error if we can't get it.
self->SetVel(luaX_tovec(L, 2));
return 0;

// SetPos()

GameObject * self = luaX_checkgameobject(L, 1);
self->SetPos(luaX_topos(L, 2));
return 0;

Cheers,
Christian Tellefsen.