From: David S. <on...@gm...> - 2011-11-20 14:18:50
|
On Sun, 20 Nov 2011 01:21:48 +1000 David Seikel <on...@gm...> wrote: > I'm not sure what you where thinking, perhaps that the user > could pass in a table to be filled in? Seems odd. > > There's a few of these, I'll just leave a FIXME comment for now, but > I'll probably remove the check before the release. On a related note, I'm not so sure about this business of reusing tables that are passed in as parameters for the results to be returned. I don't think that sort of thing is used anywhere else in lua, AND we are returning the result table anyway. It's quite nice that things like colour and coords can be passed back and forth as a table. Even better is that excess stuff in these tables is ignored if passed in as arguments. Better still that they can be passed in as separate values. map:lighting() accepts one set of 3D coords, and two sets of colours. map:rotate3d() accepts two sets of 3D coords. map:zoom() accepts two sets of 2D coords. The problem with these, if using the generic argument scanner I wrote, based on the several specialized argument scanners you wrote, is that it tries to reuse the table passed in to return results, but A) which table? B) it does a reset of the stack, that causes problems for the next scanner call that tries to get the next set of arguments. Well, OK, those three don't return any values, so A is moot. And B is moot for those three anyway, since the stack reset is bypassed. I still think it might be a problem for future API additions. I still think it would be much cleaner to NOT reuse passed in tables, and to not pass values back in optional passed in tables. This solves both problems mentioned in this thread, and makes things cleaner all around. So that would mean that we remove the bool that tells the argument scanner to reuse or create a table, and have the generic "return results in a table" function create it's own table. And remove that lua_istable check mentioned in the last email. I'll double check if the example is using that sort of thing, then make these changes and commit. You can revert if you disagree. -- A big old stinking pile of genius that no one wants coz there are too many silver coated monkeys in the world. |