Okay, as you might already know, I like looking at other's people source. Obviously, for learning purposes.
But at the same time, i sometimes notice some fun/strange coding habits. Or design patterns that results in a very clean code.
Note: Please keep in mind one thing. This is not for bashing anyone. But sharing useful tips, or gently teasing some folks.
![Mega Grin :megagrin:](./images/smilies/ms-megagrin.png)
I'll start with Leafo. Seen in ExoSlime source.
So, Leafo has the strange habit of adding _0 to each of his variables...
Well, maybe he can explain.
![Ultrahappy :ultrahappy:](./images/smilies/ms-ultrahappy.png)
Code: Select all
mixin_object = function(self, object, methods)
local _list_0 = methods
for _index_0 = 1, #_list_0 do
local name = _list_0[_index_0]
....
if keys then
local _list_0 = keys
for _index_0 = 1, #_list_0 do
local key = _list_0[_index_0]
....
_base_0.__index = _base_0
if _parent_0 then
setmetatable(_base_0, _parent_0.__base)
end
...
{
__index = function(cls, name)
local val = rawget(_base_0, name)
if val == nil and _parent_0 then
return _parent_0[name]
else
return val
end
end,
__call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...)
return _self_0
end
}
....
__call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...)
return _self_0
end
})
_base_0.__class = _class_0
return _class_0
Well share you own, or things you've seen, no matter what the programming language is or the framework/engine is.
Though Lua/love2D are preferred.