4 ms·
About point 2: the author is probably ignorant of ast module (http://docs.python.org/library/ast.html http://docs.python.org/library/ast.html), which allows the
by DanielRibeiro 16y ago
About point 2: the author is probably ignorant of ast module (http://docs.python.org/library/ast.html http://docs.python.org/library/ast.html), which allows the programmer to take any ast and recompile it to anything he/she wants (in runtime, unlike Lisp macros, but alike parse tree and ruby2ruby in ruby).
This feature allows you to transform things like "1, minute" into "Minute(1)", enabling dsls, and "wrecking havoc" all over. In ruby, you don't have to do this, as there are simpler and less powerful metaprogramming tools.
So yeah. Just because you have a shotgun, it doesn't mean you can't use it to kill a fly. Of course, the really important question is not if you can, but if you should. And it is always better that this decision is left for the users of the language than to its creators.
- jacobian 16y agoSo "the author" is Alex Martelli, a long-time Python user, contributor, and winner of the 2006 Frank Willison award which is given each year for outstanding contribution to the Python community. I highly doubt he's "ignorant" of anything when it comes to Python... A better theory is this article is from 2003, but the ast module was added in Python 2.6, which was released in 2008. (I agree with everything you've said in the second and third paragraphs, but, man, try to give people a little credit before you assume they're ignorant, 'k?)
- DanielRibeiro 16y agoThanks for the info. I was ignorant of the author and post date. I seriously did not want to imply (the incorrect fact) that the author was ignorant in general, but of a single matter (which is kinda unknown, so I'd expect most be to be oblivious to it). I am equaly sorry for the bad choice of words...
- didip 16y agoIt takes efforts to write a simple Transformer using ast. Along the way of making one, your instinct will tell you that doing so is a bad idea, probably. In Ruby, meta-programming is always powerful and always so easy to use. I don't have problem using these methods, but it pains me when some crappy monkey-patching-flavored gem (For example, cache-money) decided to bite me intermittently. Or when debugging the code of some kick-ass-ninja-rockstar programmer where he decided to generate methods using both class_eval and instance_eval (along the way, generating the "def statements" using string interpolation) inside a module that supposed to be injected into ActiveRecord object. I do agree with your last paragraph completely. The real ninja is capable of stopping himself from beheading anyone he sees just because he can.