General musings on programming languages, and Java.

Friday, January 12, 2007

Closures without instances, and safer non-local returns

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.


JodaStephen said...

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.

Ricky Clarkson said...

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.

Arianuz said...
This comment has been removed by a blog administrator.

Blog Archive

About Me

A salsa dancing, DJing programmer from Manchester, England.