Re: middleclass & middleclass-extras: OOP for LUA
Posted: Fri Nov 26, 2010 6:00 pm
Just a clarification: I'm not ignoring thelinx. On the contrary: I'm very grateful for him to having taken the time to send a patch. He's the man.
It's just been a very busy week and I haven't had time to do much Lua. And I'm not sure I will be able to program this weekend, neither.
Thelinx's change request changes the init.lua files so they it is more or less 'impervious' to middleclass(-extras) being put inside a folder (/lib/middleclass instead of just /middleclass/).
My initial impression was that the 'standard' way of dealing with this was modifying package.path (on the example before, package.path = '/lib/?;' .. package.path).
I'm not really sure about what option do I like the most:
I'm split about this. thelinx's solution is simple. Current solution is more 'semantic' ... but then, middleclass 's supposed to make common things easy to do...
So I'll probably end up accepting thelinx's solution. I'm taking my time because I want to do tests before including them. More precisely, I want to test that everything works ok happens if package.path is modified, and if middleclass is transformed into a luarock.
In the meantime, if anyone else has any opinion in the whole package.path-modified-vs-including-lib-easily, I'd be glad to hear it.
It's just been a very busy week and I haven't had time to do much Lua. And I'm not sure I will be able to program this weekend, neither.
Thelinx's change request changes the init.lua files so they it is more or less 'impervious' to middleclass(-extras) being put inside a folder (/lib/middleclass instead of just /middleclass/).
My initial impression was that the 'standard' way of dealing with this was modifying package.path (on the example before, package.path = '/lib/?;' .. package.path).
I'm not really sure about what option do I like the most:
Code: Select all
-- Current solution (while we are at it, we could also include init.lua in the loading)
package.path = '/lib/?;/lib/?/init.lua' .. package.path
...
require('middleclass')
-- thelinx's solution
require('lib.middleclass.init')
So I'll probably end up accepting thelinx's solution. I'm taking my time because I want to do tests before including them. More precisely, I want to test that everything works ok happens if package.path is modified, and if middleclass is transformed into a luarock.
In the meantime, if anyone else has any opinion in the whole package.path-modified-vs-including-lib-easily, I'd be glad to hear it.