Pythonic class definition
An alternative JavaScript class frameworkで見つけたPythonicなクラス定義方法。
以下は自分用にちょっとだけいじったクラス定義関数。
class = function(base, props) { var constructor, key, result; if (props.hasOwnProperty('__init__')) { constructor = function(){ return props.__init__.apply(this, arguments); } } else { constructor = function(){}; } constructor.prototype = new base(); for (key in props) { if (key != '__init__') { constructor.prototype[key] = props[key]; } } // ad-hoc solution constructor.TYPE = "CLASS"; return constructor; }