RE: Discussion: Closures
"Yemi D. Bedu" <yemi-DnQzskBZRmpWk0Htik3J/[email protected]> Thu, 3 Feb 2005 16:03:38 -0500
| Newsgroups | gmane.comp.java.beanshell.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
What might also be nice is if we have something similar to Perl (I think
its Perl):
X = closure([cat, dog, fish]){
Print($1);
someMethod($2);
$3 = $3 + 1;
};
Or
X = closure(3){ // 3 parameters
Print($1);
someMethod($2);
$3 = $3 + 1;
};
Then
R = 3;
X.doClose(1, 4, R);
>> 1
>> you gave "4"
Print(R);
>> 4
-----Original Message-----
From: beanshell-developers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:beanshell-developers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of
Shankar Unni
Sent: Thursday, February 03, 2005 12:54 PM
To: 'BeanShell Developers'
Subject: RE: [Beanshell-dev] Discussion: Closures
> 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
_______________________________________________
Beanshell-developers mailing list
Beanshell-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
-------------------------------------------------------
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