Re: Discussion: Closures
Patrick Niemeyer <[email protected]> Thu, 3 Feb 2005 13:56:32 -0600
| Newsgroups | gmane.comp.java.beanshell.devel |
|---|---|
| Message-ID | <[email protected]> |
On Feb 3, 2005, at 1:00 PM, Bob Lee wrote:
> foo = closure(bar) { print(bar); };
> foo(5);
>
> I'd still prefer something like this:
>
> foo = (bar) { print(bar); };
> foo(5);
Again, it looks good unless you have no args:
foo=() { print(bar); };
someMethod( () { print(bar); } );
But maybe that syntax would grow on me if I looked it for a while.
I don't know.
> Or even the ruby/groovy approach:
>
> foo = { bar | print(bar); };
> foo(5);
That's much closer to the original proposal:
foo = callable( bar, print(bar); };
foo(5);
I'm not sure why they bothered with the '|' syntax... it's probably
necessary because of some other ambiguity in the language. We wouldn't
suffer from that due to the explicit (proposed) method call syntax.
Pat
-------------------------------------------------------
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