On Thu, 26 Apr 2012 02:54:58 +1000
Steven D'Aprano
Mark Shannon wrote:
I don't know if this is a good idea or not, but the fact that to it can be implemented by removing a single restriction in the compiler suggests it might have some merit. Do you really mean to say that *because* something is easy, it therefore might be a good idea?
I read it as an expression of the language design philosophy that the
best way to add power is to remove restrictions. Personally, I agree
with that philosophy, as removing a single restriction is a much
better alternative than having a flock of tools, syntax and special
cases to compensate. Compare Python - where functions are first-class
objects and can be trivially passed as arguments - to pretty much any
modern language that restricts such usage.
That said, "more power" is not always the best choice from a language
design point of few. In this case there's really only one use case for
lifting the restriction against return in classes and modules, and the
problems already pointed out that lifting this restriction creates
outweigh the benefits of that use case.
-1.