It's possible to implement synchronous closures without instances, and to make non-local returns in closures not subject to unchecked exceptions. This article explains why. I like using Google Docs as a word processor, but the last time I published to blogger automatically from it, I lost some formatting, and even a random backslash, so this time I'm not going to bother. The actual article is here. Comment on this blog.
CodeSOD: Secondary Waits
1 day ago
3 comments:
The checked exception is quite clever, it just doesn't feel quite right. Surely it would essentially mean that no-one uses that construct?
Closures without instances is where I started on this many moons ago. When I spoke to the guys at Javapolis, they preferred to use hotspot to deal with this.
Stephen (Colebourne?),
You're right, because of Java's exception syntax, it would end up that way, but that's a good thing. Non-local transfers in closures that are not guaranteed (restricted) to run synchronously are predictable failures.
I outlined a way of handling it centrally anyway, allowUnsafeReturns.
I know where Neal is coming from about Hotspot, short-lived instances are extremely cheap, including short-lived exceptions.
But then, his solution doesn't actually allow javac to make the optimisation of removing the instance.
Post a Comment