related link
John Rose
John.Rose at Sun.COM
Tue Feb 9 11:22:24 PST 2010
On Feb 8, 2010, at 11:03 AM, Neal Gafter wrote:
> FYI, experience with languages that support "non-local return" (Scala,
> Ruby, etc) has resulted in a remarkable absence of scary things
> happening. They're really quite boring and ordinary once you try
> them.
...and Lisp, Smalltalk. The experience with such constructs spans almost the entire history of software. People who've actually used such constructs are not afraid of them.
The experience of Ruby particularly shows the chaos you get into when you come to the "return" fork and take both sides: Now they have multiple constructs that handle "return" differently, and they are having to back and fill (in 1.9) to rationalize the mess. The Python designers were wiser and restricted closure bodies to simple expressions, to dodge the "return" question completely.
Regarding "scariness": Given any language extension proposal, a significant number of people (not just a few) will be vocally afraid of the unknown effects of the proposal. Of those who were excited enough to comment on Inner Classes in 1.1, about 30% accused us of ruining Java. Some still think so, probably, but on the whole it doesn't matter. For most people, the unknown eventually became the known, and it was (to everyone's relief) a livable reality.
Regarding the specific dangers of uplevel branch: An unmatched uplevel branch, which causes an exception when executed, is annoyingly dynamic. It is self-diagnosing, exactly like a NPE or CCE. And BGGA has a novel static check for restricting branches to appropriate APIs, so there's a static story too, unlike NPE or CCE. And (as those who have used such things know by experience) the problem comes up much less often than NPE or CCE does in Java.
Compared with the largely-hypothetical dangers of uplevel branches, I am personally much more afraid, based on experience with Lisp, of unexpected, undiagnosed effects of the "dotimes bug"[1] with captured mutable locals.
-- John
[1] http://blogs.msdn.com/ericlippert/archive/2009/11/12/closing-over-the-loop-variable-considered-harmful.aspx
See also my comment on that web page.
More information about the closures-dev
mailing list