3 ms·
I think the way Lua handles it is much better. If you have object foo of class Foo with method bar, accessing it like foo.bar does no magic on it. You would hav
by user234683 8y ago
I think the way Lua handles it is much better. If you have object foo of class Foo with method bar, accessing it like foo.bar does no magic on it. You would have to call it as foo.bar(foo, ...) if you wanted to access the method with a dot. Only foo:bar will do the magic on it. If you call it as foo:bar(...) then the object will be passed to the first parameter. This follows "explicit is better than implicit" much better than the implicit self parameter in my opinion.
- fiddlerwoaroof 8y agoI'm no Lua expert, but isn't this because Lua's object model is more prototypical inheritance than a standard class-based model like python has?