callsuper in kissy
Post on 12-Sep-2014
275 views
DESCRIPTION
implement super in KISSYTRANSCRIPT
Super
• Call super class method from sub class method with same signature.
Super in other language
• Java
• constructor default super()
– keyword
base() sub()
Super in other language
• Java
• Constructor Explicit call super
– Must be on first line
– keyword
base(int i) sub()
Super in other languages
• Java
• Explicit call super.xx in overriden method
– object
sub run() base run()
Super in other languages
• Python
• Super
– Build-in bind function( mro )
– Constructor is same with method
• No first line constraint
• Allow multiple inheritance
Base init Sub init Sub run Base run
Super in other languages
• JavaScript
• But flexible
Super in KISSY
• KISSY
– Build own class system
Super in KISSY
• callSuper
• Built-in bind function (~python)
• No need to specify method name
• Does not allow multiple inheritance – Extensions(Mixins) + single Inheritance + plugin
Usage
Base init M1 init Sub init Sub run Base run Sub destroy M1 destroy Base destroy
Bind usage
• Closure?
internal
• arguments.callee.caller
• __owner__/__name__
refer
• http://docs.python.org/3/tutorial/classes.html
• http://www.python.org/download/releases/2.3/mro/
• http://docs.oracle.com/javase/tutorial/java/IandI/super.html
• https://github.com/kissyteam/kissy/tree/master/src/base
Acknowledgements
• goto100(义宇)