lua-users home
lua-l archive

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


Hi All,

> I recently converted a couple thousand lines of code to the 4.0 API and
> found the resulting code to be smaller and cleaner.  YMMV.

I converted some 3k lines and at first I hated it. I've been programming
with the old style for some 4-5 years and it took me some time to get
used to the new style. I don't think the code is smaller or cleaner.
It's just different. The convertion process is sometimes frustrating,
though (I basically rewrote the Lua bind). 

The new API opens the way for a lot of nice tricks now that the
incomming and outgoing values lie on the same stack. And I am almost
prefering the new API now. That is, if I would start a new project.

Wether you are going to have a lot of work converting old API code to
new API code or not, depends on your old API programming style. In my
experience, if your C functions pass lua_Objects back and forth auxiliar
C functions, you might have some trouble: beware passing negative
(relative) stack indexes to other C functions as their stack use may
invalidate (shift) them. (You can always convert them to positive
(absolute) at function entry).

Besides, if it is more efficient as it surely is, I can live with it.

Regards,
Diego.