lua-users home
lua-l archive

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



Well done, and most people seem to agree with you on the use of strings the way you've done.

However.

There's one biiiig but in there, and that is documentation & learning curve. You'd basically have to redocument all of the binded API, to tell people which way it should be used from Lua. And, most likely, they wouldn't, since that only adds to the (imho seeming) exotism of the language.

I'm all for "impedance matching" in the binding, don't get me wrong. Lua bindings should work the Lua way; use multiple return values etc. tools that we do have available, and which are efficient. A program should look _nicer_ when done in Lua than in any other language. :)

At the same time, its terminology should be as close to the original, most often C library, which is being documented and also written about in books - i.e. SDL has numerous books about it. For this reason, sidestepping GL_COLOR_BUFFER_BIT -> "Color" is a very bad thing. And even "GL_COLOR_BUFFER_BIT" would be...

The only major issue in regard to native vs. Lua working differently, was the SDL main loop. In C, it returns 0/1 but in Lua it returns false/true. This means some code examples are bound to work, and others not. Or the other way round. Such issues need, of course, to be documented by the binding.

-asko


Alex Queiroz kirjoitti 22.9.2006 kello 14.39:

Hallo,

On 9/21/06, Sam Roberts <sroberts@bycast.com> wrote:

>From an extension point of view, when I'm using lua to extend my C
libraries, I find lack of a facility thats is so useful when extending C to be slightly surprising, since in general much of lua seems carefully
designed to make what interacting with C easy and powerful (upvalues,
environments specifically useful to C functions, etc.).


     For a *very* thin OpenGL binding I once wrote I used

GL.clear("Color", "Depth")

for

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

and I was able to manipulate large terrains with almost the same speed
of a similar C program (the terrain simplifier was written in C in
both cases). I don't think the loss of readability was worth the few
extra miliseconds.

--
-alex
http://www.ventonegro.org/