RE: Discussion: Closures

"Shankar Unni" <[email protected]> Thu, 3 Feb 2005 09:53:37 -0800
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
> One possibility would be to use another eval-like method.  
> For example, it could be named callable().  It could return a 
> closure with a call() method, and the whole thing might map 
> to the Java type java.util.concurrent.Callable where 

And how is that different from java.lang.Runnable and run()? Oh, I see -
Callable.call() can return an Object, but run is a void run().

The only minor quibble I might have is for the parameter declaration syntax.
Does this not look more natural?:

  x = callable() {
     foo = someMethod();
     bar++;
  };

  z = callable(foo, bar) {
     print(foo);
     someMethod(bar);
  };

  x.call();
  z.call(foo,bar);




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl