lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Sam Pagenkopf <ssaammp@gmail.com> 于2018年11月27日周二 上午9:26写道:
>
> object.component.method(object) => object:component.method()
> ^ I also tried this syntax (and was sad it didn't work), but it's not so bad. That strategy makes for cross-cutting communication between components, which is not the greatest thing. It also assumes that call your parents, but not your grandparents! Here's my alternative, a "parent" variable:

My alternative is when we add a component to an object, I copy all the
methods of component into object's meta table, and we can use it in
this way :

object:component_method(...) => object.component.method(object, ...)


-- 
http://blog.codingnow.com