6 ms·
I wonder how multiple inheritance is handled by this webdev holy grail. I know CoffeeScript had some issues handling its certain attributes* within its construc
by solox3 13y ago
I wonder how multiple inheritance is handled by this webdev holy grail. I know CoffeeScript had some issues handling its certain attributes* within its constructors, so it'll be interesting to see how pythonium does the same and beyond.
* forgot what
- acjohnson55 13y agoI hope your object model doesn't require understanding the MRO to trace the code, unless you're doing some serious library plumbing that I can't even really fathom using in front-end code right now. But I'm fairly certain you could mimic those semantics with wrappers around prototypal inheritance somehow.
- amirouche 13y agoIt's not possible to use prototypal inheritance to mock even simple inheritance since “method = object.metod; method();” loose the reference to “this” as “object”, it's a gotcha in the lower level mode Veloce of Pythonium that I tried to explain in https://github.com/pythonium/pythonium/wiki/Pythonium-Veloce-Cookbook#methods-as-callbacks https://github.com/pythonium/pythonium/wiki/Pythonium-Veloce.... The MRO and thus multiple inhertiance is implemented in pythonium_create_class https://github.com/pythonium/pythonium/blob/master/pythonium/lib/runtime.py#L114 https://github.com/pythonium/pythonium/blob/master/pythonium...
- acjohnson55 13y agoYeah, that's why I phrased it "wrappers around". Check out https://github.com/lukasolson/Backbone-Super https://github.com/lukasolson/Backbone-Super for example, which wraps and replaces Backbone.extend.
- amirouche 13y agoI never mentionned super. Anyway, thanks for the link.
- jashkenas 13y ago> I know CoffeeScript had some issues handling its certain attributes* > within its constructors Oh really? Do tell.
- solox3 13y agoclass a constructor: -> # conventionally logs 3 console.log @c class b extends a c = 3 new b() # logs undefined
- jashkenas 13y agoNot quite. Key-value properties use the colon syntax. Regular assignment is for local variables. Your "c" is a local variable within the class body of "b", and should absolutely not be visible from the constructor of "a". Here's the corrected version: class a constructor: -> console.log @c class b extends a c: 3 new b() # logs 3
- solox3 13y agoToday the whole office learned. Thanks a bunch, Jeremy!