Python Decorators in Ruby(yehudakatz.com)
yehudakatz.com
Python Decorators in Ruby
http://yehudakatz.com/2009/07/11/python-decorators-in-ruby/
2 comments
If you read PEP 318, http://www.python.org/dev/peps/pep-0318/, it's easy to see how much thought went into what is syntactic sugar.
I agree. And it's not that Python strictly needed the "@"-syntax in the first place. They just implemented ("hardcoded", as the article calls it) it to make it obvious what is happening.
Gregory Brown recently posted a different take on Decorators using Ruby's delegate standard library.
Worth a look : http://blog.rubybestpractices.com/posts/gregory/008-decorato...
Worth a look : http://blog.rubybestpractices.com/posts/gregory/008-decorato...
IOW, complete flexibility is not the only end goal: adding predictability as well makes the feature twice as nice. There are many possible syntaxes for doing roughly similar things, but if every app uses a different one, life can be hell for whoever has to read the code.