Block Lambdas: break and continue

Axel Rauschmayer axel at rauschma.de
Sat Jan 14 12:35:38 PST 2012


> If I understand your suggestion, you're proposing that non-local break and continue should be exposed as standard exceptions, and then implementors of loop-like abstractions could choose to catch them.
> ...
> Did I understand your suggestion correctly?

Yes. I was thinking about the BGGA closure proposal that Allen also linked to: http://www.javac.info/closures-v05.html

> This *may* not violate TCP (I'm not quite sure), but I'm not enthusiastic about the idea. The semantics is significantly more complicated, and it requires you to understand whether a higher-order function like forEach is catching these exceptions or not. So it becomes an additional part of the API of a function. If someone doesn't document what they do with BreakException and ContinueException, then writing callbacks you won't actually be able to predict what `break` and `continue` will do.

I don’t think it’s a must-have, but whenever you catch exceptions, you have similar issues.

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120114/a3f19860/attachment-0001.html>


More information about the es-discuss mailing list