From: Furash Gary <furashg@mc...> - 2005-06-22 14:23:27
I added your commments from an earlier post re anon closures to the
From: Pat Niemeyer [mailto:pat@...]=20
Sent: Wednesday, June 22, 2005 7:22 AM
To: Furash Gary
Subject: Re: [Beanshell-users] Using method closures...
> I know Beanshell trivially supports method closures (things that=20
> return a "this" reference). Closures are supposed to be "cool" (i.e.,
> Does anyone have any examples of situations where they are useful?
I think that the "cool" stuff generally centers around what I guess
you'd call anonymous closures... and utilities that accept those as
part of their API.
What that means is the ability to basically pass a chunk of code as an
argument to a method and have the method evaluate it when it needs it,
with various kinds of control over binding variables to it...
BeanShell doesn't currently have a syntax for making these kinds of
closures... only named ones (the return 'this' kind) that are bound
into the namespace in which they were created). There is nothing
technically difficult about doing this and in fact BeanShell has all the
tools to do it... you could sort of roll your own using the
setNameSpace() or namespace setParent() methods and the this.caller
reference. But that's not friendly of course.
We will have something on this front soon.