Other Bloggers

  • Graham Glass
    Entreprenurial free-thinker who loves adventure.
  • Danil Suits
  • Brian Oxley
    Former ThoughtWorks colleague, fellow Rice alum.
  • Jef Newsom
    I am a small business owner with a passion for my family, music, and leveraging technology to create winning business solutions.
  • Greg Vaughn
    Agile-minded developer in the mortgage industry.
Blog powered by TypePad

« JOpt Simple 2.4-beta1 released | Main | JavaOne 2008 -- Day 1 preview »

May 01, 2008

Comments

B. K. Oxley (binkley)

Look at section #2 in the 0.5 specification on closure conversion.

If I understand the language correctly, you can use type java.lang.Void in place of the void keyword. I think this exegesis covers your case:

"The closure conversion supports converting a function that yields no result to an interface whose method returns java.lang.Void. In this case a null value is returned from the function. This is necessary to write APIs that support completion transparency: that is, in which an invocation of the API can return normally if and only if the function that is passed to it can complete normally."

Or not. There is no example in the specification for this case that I found.

Stephen Swensen

I would suggest you simply create two categories of functors, those that return Void, and those that return all other Objects. C-based languages treat Void functions specially, it creates some problems, but I usually like to stay within the grain of whichever languages I'm working with.

Check out: http://www.codeproject.com/KB/java/FunctionalJava.aspx

a package of generic functors and an immutable Iterable type featuring method chaining, lazy evaulation, and typical functional projections like map, filter, and fold.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment