On Mon, Oct 21, 2013 at 11:53 AM, Saager Mhatre <saager.mha...@gmail.com> wrote: > On Oct 21, 2013 11:39 AM, "Dhananjay Nene" <dhananjay.n...@gmail.com> wrote: >> >> On Mon, Oct 21, 2013 at 10:55 AM, Saager Mhatre <saager.mha...@gmail.com> > wrote: >> >> > Which generally lead to poor (or at least poorer) abstractions; but I > digress. >> >> Leaky ?? :) > > For the most part, yes. > >> > >> >> I think OOPs concepts across a number of languages are quite different. >> >> You will find python having superior constructs eg. metaclasses etc. > if you were comparing Python OOP to C++/Java. >> > >> > Superior constructs implemented inferiorly. Meteclasses are much^3 more > powerful in Groovy, Ruby and SmallTalk (where some would claim Python > borrowed them from; but that's just not true.) >> >> I wonder if you meant syntactically/stylistically. Would be keen to > learn, if there are examples where ruby / groovy (I don't know much about > smalltalk) allow things that python does not. > > Semantically! MetaClasses are a much more powerful construct in those > languages.
I'm specifically looking for evidence to support that. And I suspect it might be out there to be found , just that I haven't so far. One of my early attempts was documented here http://blog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/ > They form the core of the MetaObjectProtocol which governs the > dynamic dispatch of messages/methods. Modifications to MetaClasses > percolate to Classes and objects they are associated with and such > modifications as well as MetaClass associations can be dynamic as well as > temporary; leading to some seriously powerful use cases. The "temporary" is intriguing. I don't quite yet understand what it means .. does it mean you could say temporarily add a method and then take it out later (or some other similar capability) ? > > That's pretty much what always foiled my attempts at understanding Python > MetaClasses, I was looking for power where there was none to find. The best > comparison I could find was to Groovy's Compile time AST transforms, but > even those are even more powerful as they drop down a level of abstraction > and hand you the AST for the an rated element. AST transforms are sort of feasible but rarely done, and not sure if I would like to be a part of such an exercise. They kick in via the import hook, thus you build the AST on your own, thankfully python does provide AST helpers. Googling for python macros will show some such valiant attempts - https://github.com/lihaoyi/macropy or https://code.google.com/p/metapython/wiki/Tutorial _______________________________________________ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers