kikito / middleclass

Object-orientation for Lua
https://github.com/kikito/middleclass
MIT License
1.77k stars 190 forks source link

aClass.subclasses never used? Why this field is always empty? #61

Closed winterwolf closed 4 years ago

winterwolf commented 4 years ago

Hello! I inspected your code and its behavior in lovebird. I created a chain of classes, inherited from each other, watched in their subclasses fields and all these fields are empty! Maybe I don't get something but I think there is a bug: https://github.com/kikito/middleclass/blob/6102f676c2da6bd395b3c32b1411bb70eea0fac9/middleclass.lua#L154 It sholud look like this:

self.subclasses[name] = subclass

Also I can be wrong, but I feel that for loop in _propagateInstanceMethod at lines 53-58 does nothing useful. https://github.com/kikito/middleclass/blob/6102f676c2da6bd395b3c32b1411bb70eea0fac9/middleclass.lua#L53-L57

winterwolf commented 4 years ago

I think I'm starting to understand how it works. It looks like the table is not empty, it just contains non-string keys! I am sorry, it is very difficult for me to understand this code. I really like your library, but I don't like the bloated mess inside it ;(

qaisjp commented 4 years ago

Yes, the keys are the other class objects